Non-negative real numbers $a_1,a_2,\ldots,a_n$ are such that $a_1+\ldots +a_n=k$, where $k$ is a constant. Find the maximum value of $$a_1a_2+a_2a_3+\ldots+a_{n-1}a_n+a_na_1$$ For $n=2$ we can reach $\frac{k^2}{2}$ with $a_1=a_2=\frac{k}{2}$.
For $n=3$ we can reach $\frac{k^2}{3}$ with $a_1=a_2=a_3=\frac{k}{3}$.
For $n\geq 4$, I suspect $\frac{k^2}{4}$ is the limit, at least when $n$ is even, since we can split $k$ into $$S=a_1+a_3+\ldots+a_{n-1}$$ $$k-S=a_2+a_4+\ldots+a_n$$ Notice that the product $S(k-S)$ contains all the terms of the expression we want to maximise. In other words $$a_1a_2+a_2a_3+\ldots+a_{n-1}a_n+a_na_1$$ $$\leq (a_1+a_3+\ldots+a_{n-1})(a_2+a_4+\ldots+a_n)$$ $$=S(k-S)=\frac{k^2}{4}-(S-\frac{k}{2})^2\leq\frac{k^2}{4}$$