And David's heart condemned him after he had numbered the people. So David said to the LORD, "I have sinned greatly in what I have done; but now, I pray, O LORD, take away the iniquity of Your servant, for I have done very foolishly."
2 Samuel 24:10
Surrounding context
24:9 Then Joab gave the sum of the number of the people to the king. And there were in Israel eight hundred thousand valiant men who drew the sword, and the men of Judah were five hundred thousand men.
24:10 And David's heart condemned him after he had numbered the people. So David said to the LORD, "I have sinned greatly in what I have done; but now, I pray, O LORD, take away the iniquity of Your servant, for I have done very foolishly."
24:11 Now when David arose in the morning, the word of the LORD came to the prophet Gad, David's seer, saying,