## Problem I-4

Determine the smallest positive integer $n$ for which the following statement holds true: From any $n$ consecutive integers one can select a non-empty set of consecutive integers such that their sum is divisible by 2019 .

## (proposed by Kartal Nagy, Hungary)

Answer. $n=340$.


Solution The prime factorization of 2019 is $3 \cdot 673$. Let $p=673$.

For each integer $k$, color the three numbers $k p-1, k p, k p+1$ red, and and the six numbers $k p+\frac{p-5}{2}, k p+\frac{p-3}{2}, k p+\frac{p-1}{2}, k p+\frac{p+1}{2}, k p+\frac{p+3}{2}, k p+\frac{p+5}{2}$ blue. Now the integers are colored periodically. In a period of length $p=673$, there are 3 red integers, then 332 uncolored integers, then 6 blue integers and finally 332 uncolored integers.

The sum of the integers in a red interval is $3 k p=2019 \cdot k$, and the sum of the integers in a blue interval is $6\left(k p+\frac{p}{2}\right)=2019 \cdot(2 k+1)$. So if there is a colored interval (we mean a maximal one throughout) in the given $n$ consecutive integers, one can choose it. It is easy to see, that among any $340=332+(6-1)+(3-1)+1$ consecutive integers, there must be a colored interval. Thus the smallest $n$ (that we look for) satisfies $n \leq 340$.

Now we will show that it is not possible to choose consecutive integers in the desired way from the set $A=\{335,336, \ldots, 673\} . \quad(|A|=339$ and thus $n \geq 340$.) Assume that there exists $\{a, a+1, \ldots b\} \subseteq A$ such that

$$
2019 \left\lvert\, a+(a+1)+\cdots+b=\frac{(b-a+1)(a+b)}{2}\right.
$$

That means either $673 \mid b-a+1$, or $673 \mid a+b$. Since

$$
0\sqrt{3 m}$. Then the answer is $n=\frac{p+3 q}{2}-1$.

