Let us first show that, if n=ab, with a,b⩾2 integers, then the property in the statement of the problem does not hold. Indeed, in this case, let ak=a for 1⩽k⩽n−1 and an=0. The sum a1+a2+⋯+an=a⋅(n−1) is not divisible by n. Let i with 1⩽i⩽n be an arbitrary index. Taking j=b if 1⩽i⩽n−b, and j=b+1 if n−b<i⩽n, we have
ai+ai+1+⋯+ai+j−1=a⋅b=n≡0(modn)
It follows that the given example is indeed a counterexample to the property of the statement. Now let n be a prime number. Suppose by contradiction that the property in the statement of the problem does not hold. Then there are integers a1,a2,…,an whose sum is not divisible by n such that for each i,1⩽i⩽n, there is j,1⩽j⩽n, for which the number ai+ai+1+⋯+ai+j−1 is divisible by n. Notice that, in any such case, we should have 1⩽j⩽n−1, since a1+a2+⋯+an is not divisible by n. So we may construct recursively a finite sequence of integers 0=i0<i1<i2<⋯<in with is+1−is⩽n−1 for 0⩽s⩽n−1 such that, for 0⩽s⩽n−1,
ais+1+ais+2+⋯+ais+1≡0(modn)
(where we take indices modulo n ). Indeed, for 0⩽s<n, we apply the previous observation to i=is+1 in order to define is+1=is+j. In the sequence of n+1 indices i0,i1,i2,…,in, by the pigeonhole principle, we have two distinct elements which are congruent modulo n. So there are indices r,s with 0⩽r<s⩽n such that is≡ir(modn) and
air+1+air+2+⋯+ais=j=r∑s−1(aij+1+aij+2+⋯+aij+1)≡0(modn)
Since is≡ir(modn), we have is−ir=k⋅n for some positive integer k, and, since ij+1−ij⩽n−1 for 0⩽j⩽n−1, we have is−ir⩽(n−1)⋅n, so k⩽n−1. But in this case
air+1+air+2+⋯+ais=k⋅(a1+a2+⋯+an)
cannot be a multiple of n, since n is prime and neither k nor a1+a2+⋯+an is a multiple of n. A contradiction.