18.5. (Jury, Sweden, 79). For given numbers $n \geqslant 2$ and $a>0$, find the maximum value of the sum $\sum_{i=1}^{n-1} x_{i} x_{i+1}$ under the condition that $x_{i} \geqslant 0(i=1, \ldots, n)$ and $x_{1}+\ldots+x_{n}=a$.
18.5. Let $\max \left(x_{1}, \ldots, x_{n}\right)=x_{k}$. Then

$$
\begin{aligned}
& \sum_{i=1}^{n-1} x_{i} x_{i+1}=\sum_{i=1}^{k-1} x_{i} x_{i+1}+\sum_{i=k}^{n-1} x_{i} x_{i+1} \leqslant \\
& \leqslant x_{k} \sum_{i=1}^{k-1} x_{i}+x_{k} \sum_{i=k+1}^{n} x_{i}=x_{k}\left(a-x_{k}\right) \leqslant\left(\left(x_{k}+a-x_{k}\right) / 2\right)^{2}=a^{2} / 4
\end{aligned}
$$

Equality is achieved, for example, when $x_{1}=x_{2}=a / 2, x_{3}=\ldots=x_{n}=0$. Therefore, the maximum value is $a^{2} / 4$.