Lemma. The sum of any forty consecutive numbers is not less than 80.

Proof. Let the numbers $a_{1}, \ldots, a_{40}$ be written consecutively. Among the numbers $b_{0}=0, b_{1}=a_{1}, b_{2}$

![](https://cdn.mathpix.com/cropped/2024_05_06_a16cba6403f5db62d5b1g-36.jpg?height=58&width=2033&top_left_y=1343&top_left_x=1)
be the remainder when divided by 40. Then the sum $a_{i+1} + a_{i+2} + \ldots + a_j$ is divisible by 40, and therefore not less than 80.

Estimate. Suppose $n > 1019$ numbers are written. By the lemma, the sum of the first $1000 = 25 \cdot 40$ of them is not less than $25 \cdot 80 = 2000$. The sum of the remaining numbers (at least 20) is not less than 20. Therefore, the total sum is not less than 2020. Contradiction.

Example. 25 groups of 1, $\ldots, 1, 41$ (in each group 39 ones and the number 41) and then 19 ones.

## Answer

1019 numbers.
Shapovalov A.V.

Several natural numbers are written in a row with a sum of 2019. No number and no sum of several consecutive numbers equals 40. What is the maximum number of numbers that could have been written?