Maximize $x_1x_2+x_2x_3+\cdots+x_nx_1$ Let $x_1,x_2,\ldots,x_n$ be $n$ non-negative numbers ($n>2$) with a fixed sum $S$.
What is the maximum of $x_1x_2+x_2x_3+\cdots+x_nx_1$?

Consider graph $G=(V,E)$, where $V=\{1,2,\ldots,n\}$ and corresponding sum $F(x_1,x_2,\ldots,x_n)=\sum\limits_{ij\in E}{x_ix_j}$. We will prove that for $x_1,x_2,\ldots,x_n\in[0,1]$ such that $\sum\limits_{i=1}^{n}x_i=1$ the maximum of $F(x_1,x_2,\ldots,x_n)$ is equal to $\dfrac{1}{2}-\dfrac{1}{2\omega(G)}$, where $\omega(G)$ is a clique number of graph $G$. Firstly, note that the set
$$
K=\left\{(x_1,x_2,\ldots,x_n)\mid x_i\in [0,1], \sum_{i=1}^{n}x_i=1\right\}
$$
is compact and $F$ is continious, so the maximum of $F$ is attained at some point $A_0=(x_1,x_2,\ldots,x_n)\in K$. We will suppose that among all maxima of $F$ in $E$ point $A_0$ has the least possible number of nonzero coordinates. Now we will prove that the set $C$ of vertices $i\in V$ such that $x_i>0$ form a clique in the graph $G$.
Indeed, consider two indices $i$ and $j$ such that $x_i,x_j>0$. If $ij\notin E$, then consider point $A_t(x_1,\ldots,x_i+t,\ldots,x_j-t,\ldots,x_n)\in K$ (for some small $t$) and the value of $F$ at this point. Note that
$$
F(A_t)-F(A_0)
$$
is a linear function of the variable $t$ (here we use our assumption $ij\notin E$; terms with $t^2$ can appear only in $(x_i+t)(x_j-t)$) and it's well-defined on some interval $(-\varepsilon,\varepsilon)$ (we can suppose that $A_t\in K$ for $|t|<\varepsilon$).
Since $F(A_t)-F(A_0)\leq 0$ for $|t|\leq\varepsilon$, $F(A_t)$ should be constant, so for all $t$ we have $F(A_t)=F(A_0)$. Thus, for all $t$ such that $A_t\in K$ the point $A_t$ is a maximum of $F$.
Now, observe that $x_i+x_j\leq 1$, so for $t=x_j$ point $A_{x_j}\in K$ has less nonzero coordinates than $A_0$ and it contradicts our assumption.
Thus, vertices of $C=\{i\mid x_i>0\}$ form a clique in the graph $G$. In this case we can compute and estimate the value of $F$ at $A_0$; the first inequality is a consequence of $|C|\cdot\sum\limits_{i\in C}x_i^2\geq\left(\sum\limits_{i\in C}x_i\right)^2$:
$$
F(A_0)=\sum_{ij\in E}x_ix_j=\sum_{i,j\in C, ij\in E}x_ix_j\leq\frac{|C|-1}{2|C|}\cdot \left(\sum_{i\in C}x_i\right)^2=\frac{|C|-1}{2|C|}=\frac{1}{2}-\frac{1}{2|C|}\leq\frac{1}{2}-\frac{1}{2\omega(G)}.
$$
Hence, $F(x_1,\ldots,x_n)\leq\dfrac{1}{2}-\dfrac{1}{2\omega(G)}$, as desired.
Finally, note that if $\{i_1,i_2,\ldots,i_k\}$ is a clique of size $k=\omega(G)$ in the graph $G$, then $F(x_1,\ldots,x_n)=\dfrac{1}{2}-\dfrac{1}{2\omega(G)}$, where $x_{i}=\frac{1}{k}$ if $i=i_{j}$ for some $j$ and $0$ otherwise (it follows from the previous computations).
Therefore,
$$
\max_{K} F=\dfrac{1}{2}-\dfrac{1}{2\omega(G)}.
$$

Now return to the original problem. In this case $G=C_n$ (cycle on $n$ vertices), so for $n=3$ the maximum value is $\frac{1}{2}-\frac{1}{6}=\frac{1}{3}$ and for $n>2$ it equals $\frac{1}{2}-\frac{1}{4}=\frac{1}{4}$.
