Suppose that a0,a1,…,amn−1 is a nice sequence, where we take indices modulo mn. First of all, we claim that if at=max{a0,a1,…,amn−1} then at+1−m=at+1,at+2−m=at+2,…,at−1=at+(m−1) (call these 2(m−1) terms (m−1)-pairs). Let Si=ai+⋯+ai+m−1 for each 0≤i≤mn−1. Then Si+1−Si=ai+m−ai. If there are indices t−m+1≤i,j≤t such that Si>Sj then Si−Sj≥Sj(m−1) since Si and Sj are powers of m. Therefore, it follows from mat≥Si>Sj>at that
mat−at≥Si−Sj≥Sj(m−1)>at(m−1),
a contradiction. Thus St−m+1=St−m+2=⋯=St and hence ai=am+i for each t−m+1≤i≤t−1.
(1) Let k≥2 and let a0,a1,…,amk−1 be a nice sequence. Denote by at the largest term of the sequence and delete the terms at,at+1,…,at+m−1 in the given sequence. Then the remaining sequence
a0,a1,…,at−1,at+m,as+m+1,…,amk−1
is nice by the claim.
(2) From the claim and (1), it follows that the number of (m−1)-pairs in a given nice sequence is at least m−1. Therefore, there are (m−1)2 pairs of the form (ai,ai+m) with ai=ai+m. Now consider the remainders, modulo m, of the indices of all (m−1)-pairs in the sequence. By the pigeonhole principle, there is a remainder j modulo m such that the number of pairs whose indices are exactly j modulo m is at least [(m−1)2/m]+1=m−1. Let (aki,aki+m) be such pairs, i.e., aki=aki+m, ki<ki+1 and ki≡j(modm) for each 1≤i≤m−1. Since m2>jm−1+m and
km−1+m=m+k1+i=2∑m−1(ki−ki−1)=m+k1+mi=2∑m−1mki−ki−1
we obtain ki−ki−1=m for each i. Thus ak1=ak2=⋯=akm−1=akm−1+m, completes the proof.