4. (10 points) If the sum of the digits of a natural number $n$ is subtracted from $n$, the result is 2016. Find the sum of all such natural numbers $n$.

Answer: 20245
Solution. The sum of the digits decreases quickly, so the number $n$ can only be a four-digit number. The sum of the digits of a four-digit number does not exceed 36, therefore, $n=S(n)+2016 \leq 2052$, i.e., the first two digits are 2 and 0. Then $\overline{20 x y}=$ $2+x+y+2016 ; 9 x=18$, and $y-$ is any. Adding all numbers from 2020 to 2029 gives the answer.