Maths WorkshopMaths problems with full solutions
Exercise 601Combinatorics › Pigeonhole principleM1Added 4 Nov 2026

A block of consecutive terms divisible by n

#pigeonhole#prefix sums#remainders

Statement

Let a1,a2,…,ana_1,a_2,\dots,a_n be integers. Prove that there exist i≤ji\le j such that the sum ai+ai+1+⋯+aja_i+a_{i+1}+\dots+a_j is divisible by nn.

Hint

Consider the n+1n+1 partial sums S0=0S_0=0, S1=a1S_1=a_1, S2=a1+a2S_2=a_1+a_2, …\dots, SnS_n and their remainders modulo nn.

Show solutionHide solution

Solution

Idea. A block sum is a difference of two partial sums.

Pigeonhole. The n+1n+1 numbers S0,S1,…,SnS_0,S_1,\dots,S_n have only nn possible remainders modulo nn, so two of them, say SpS_p and SqS_q with p<qp<q, have the same remainder. Then nn divides
Sq−Sp=ap+1+ap+2+⋯+aq.S_q-S_p=a_{p+1}+a_{p+2}+\dots+a_q.
Taking i=p+1i=p+1 and j=qj=q gives the required block.

Remark. The result is sharp: for n−1n-1 numbers it fails. Take a1=⋯=an−1=1a_1=\dots=a_{n-1}=1.

Lesson. Turn sums of blocks into differences of prefix sums, then apply the pigeonhole principle to remainders.