Problem

Source: KMO 2022 P3

Tags: number theory, Perfect Squares, Sequence, Integer sequence



Suppose that the sequence $\{a_n\}$ of positive integers satisfies the following conditions: For an integer $i \geq 2022$, define $a_i$ as the smallest positive integer $x$ such that $x+\sum_{k=i-2021}^{i-1}a_k$ is a perfect square. There exists infinitely many positive integers $n$ such that $a_n=4\times 2022-3$. Prove that there exists a positive integer $N$ such that $\sum_{k=n}^{n+2021}a_k$ is constant for every integer $n \geq N$. And determine the value of $\sum_{k=N}^{N+2021}a_k$.