4. Vasya, who you know from the first round, came up with $n$ consecutive natural numbers, for each he wrote down the sum of the digits, and as a result, he also got $n$ consecutive numbers (possibly not in order). For what maximum $n$ is this possible?

## SOLUTION:
Answer: when $n=18$.

Example: the numbers $392,393, \ldots 399,400,401, \ldots 409$ have digit sums of $14,15, \ldots, 21,4,5, \ldots, 13$, that is, all from 4 to 21.

Estimation. Let $n \geqslant 19$.

a) If all numbers are within the same hundred (...00-...99), then the difference in digit sums of 18 is only achieved for the numbers ...00 and ...99. Therefore, both must be included in the range, but then in a range of 100 numbers, there are only 19 different digit sums.

b) If the numbers do not fit within one hundred, then among them there is a number $x$ that ends in 00. Note that among the numbers of the previous hundred, $x-11=\ldots 89$ has the same digit sum as $x-2=\ldots 98$; and among the numbers of the next hundred, $x+10=\ldots 10$ has the same digit sum as $x+1=\ldots 01$. Therefore, $x-11$ and $x+10$ cannot be included in the considered range. But then the range contains a maximum of 20 numbers (from $x-10$ to $x+9$).

If $x=\ldots 000$, then the difference in digit sums of $x$ and $x+1$ is 26, which is too much. If, however, $x$ ends only in two zeros, then $x-10$ has the same digit sum as $x+8$, and $x-9$ has the same digit sum as $x+9$. Therefore, the range contains no more than 18 numbers, Q.E.D.