Problem

Source: RMO KV 2024 Q4

Tags: number theory



Let $n>1$ be a positive integer. Call a rearrangement $a_1,a_2, \cdots , a_n$ of $1,2, \cdots , n$ nice if for every $k = 2 ,3, \cdots , n$, we have that $a_1^2 + a_2^2 + \cdots + a_k^2$ is not divisible by $k$. Determine which positive integers $n>1$ have a nice arrangement.