Determine all positive integers $n \geqslant 3$ such that the inequality

$$
a_{1} a_{2}+a_{2} a_{3}+\cdots+a_{n-1} a_{n}+a_{n} a_{1} \leqslant 0
$$

holds for all real numbers $a_{1}, a_{2}, \ldots, a_{n}$ which satisfy $a_{1}+\cdots+a_{n}=0$.
Answer: $n=3$ and $n=4$.

For $n=3$ we have

$$
\begin{aligned}
& a_{1} a_{2}+a_{2} a_{3}+a_{3} a_{1}=\frac{\left(a_{1}+a_{2}+a_{3}\right)^{2}-\left(a_{1}^{2}+a_{2}^{3}+a_{3}^{2}\right)}{2} \leqslant \\
& \quad \leqslant \frac{\left(a_{1}+a_{2}+a_{3}\right)^{2}}{2}=0 .
\end{aligned}
$$

For $n=4$, applying the AM-GM inequality we have

$$
\begin{aligned}
& a_{1} a_{2}+a_{2} a_{3}+a_{3} a_{4}+a_{4} a_{1}=\left(a_{1}+a_{3}\right)\left(a_{2}+a_{4}\right) \leqslant \\
& \\
& \leqslant \frac{\left(a_{1}+a_{2}+a_{3}+a_{4}\right)^{2}}{4}=0 .
\end{aligned}
$$

For $n \geqslant 5$ take $a_{1}=-1, a_{2}=-2, a_{3}=a_{4}=\cdots=a_{n-2}=0, a_{n-1}=2$, $a_{n}=1$. This gives

$$
a_{1} a_{2}+a_{2} a_{3}+\ldots+a_{n-1} a_{n}+a_{n} a_{1}=2+2-1=3>0 .
$$