The eighteenth question: Given an integer $n \geq 2$, let $x_{i} \in [0,1] (1 \leq i \leq n)$. Try to find the maximum value of $\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|$, where $\mathrm{x}_{\mathrm{n}+1}=\mathrm{x}_{1}$.
The 18th question:
Prove: When $n$ is even, take $x_{2 i-1}=1, x_{2 i}=0\left(1 \leq i \leq \frac{n}{2}\right)$, then $\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|=\frac{n}{2}$; when $n$ is odd, take $x_{2 i-1}=1, x_{2 i}=0\left(1 \leq i \leq \frac{n-1}{2}\right), x_{n}=\frac{1}{2}$, then $\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|=\frac{n}{2}-\frac{1}{4}$. 
Next, we prove: $\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right| \leq \frac{n}{4}+\frac{\left[\frac{n}{2}\right]}{2}$. 
We use induction on $n$.
When $n=2$, assume $x_{1} \geq x_{2}$, then $x_{1}\left|x_{1}-x_{2}\right|+x_{2}\left|x_{2}-x_{1}\right|=x_{1}^{2}-x_{2}^{2} \leq 1$, the conclusion holds. Assume the conclusion holds for $n-1$, now consider the case for $n(n \geq 3)$.
(1) When $n$ is odd, in the sequence $x_{1}, x_{2}, \ldots, x_{n}, x_{1}, x_{2}$, there must be three consecutive terms that are monotonic. Assume they are $x_{n-2}, x_{n-1}, x_{n}$.
(1) If $x_{n-2} \leq x_{n-1} \leq x_{n}$, then by the induction hypothesis:
$\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|$
$=\sum_{i=1}^{n-3} x_{i}\left|x_{i}-x_{i+1}\right|+x_{n-2}\left(x_{n-1}-x_{n-2}\right)+x_{n-1}\left(x_{n}-x_{n-1}\right)+x_{n}\left|x_{n}-x_{1}\right|$
$=\sum_{i=1}^{n-3} x_{i}\left|x_{i}-x_{i+1}\right|+x_{n-2}\left|x_{n-2}-x_{n}\right|+x_{n}\left|x_{n}-x_{1}\right|+\left(x_{n}-x_{n-1}\right)\left(x_{n-1}-x_{n-2}\right)$
$\leq \frac{n-1}{4}+\frac{\left[\frac{n-1}{2}\right]}{2}+\frac{\left(x_{n}-x_{n-2}\right)^{2}}{4}$
$\leq \frac{n-1}{4}+\frac{\left[\frac{\left[\frac{2}{2}-1\right.}{2}\right]}{2}+\frac{1}{4}=\frac{n}{4}+\frac{\left[\frac{n 2}{2}\right]}{2}$
The conclusion holds.
(2) If $x_{n-2} \geq x_{n-1} \geq x_{n}$, then by the induction hypothesis:
$$
\begin{array}{l}
\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right| \\
=\sum_{i=1}^{n-3} x_{i}\left|x_{i}-x_{i+1}\right|+x_{n-2}\left(x_{n-2}-x_{n-1}\right)+x_{n-1}\left(x_{n-1}-x_{n}\right)+x_{n}\left|x_{n}-x_{1}\right| \\
=\sum_{i=1}^{n-3} x_{i}\left|x_{i}-x_{i+1}\right|+x_{n-2}\left|x_{n-2}-x_{n}\right|+x_{n}\left|x_{n}-x_{1}\right|-\left(x_{n-2}-x_{n-1}\right)\left(x_{n-1}-x_{n}\right) \\
\leq \frac{n-1}{4}+\frac{\left[\frac{n-1}{2}\right]}{2}<\frac{n}{4}+\frac{\left[\frac{n}{2}\right]}{2}
\end{array}
$$
The conclusion holds.
(2) When $n$ is even.
(1) If the sequence $x_{1}, x_{2}, \ldots, x_{n}, x_{1}, x_{2}$ contains three consecutive monotonic terms. Similarly to the case when $n$ is odd, using the induction hypothesis:
$$
\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right| \leq \frac{n-1}{4}+\frac{\left[\frac{n-1}{2}\right]}{2}+\frac{1}{4}=\frac{n-1}{2}<\frac{n}{4}+\frac{\left[\frac{n}{2}\right]}{2}
$$
The conclusion holds.
(2) If the sequence $x_{1}, x_{2}, \ldots, x_{n}, x_{1}, x_{2}$ does not contain three consecutive monotonic terms. Assume $x_{2 i-1} \geq x_{2 i}$, $x_{2 i} \leq x_{2 i+1}\left(1 \leq i \leq \frac{n}{2}\right)$. Let $x_{n+2}=x_{2}$, then
$$
\begin{array}{l}
\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|=\sum_{i=1}^{n}\left(x_{2 i}\left|x_{2 i}-x_{2 i+1}\right|+x_{2 i+1}\left|x_{2 i+1}-x_{2 i+2}\right|\right) \\
=\sum_{i=1}^{n}\left(x_{2 i}\left(x_{2 i+1}-x_{2 i}\right)+x_{2 i+1}\left(x_{2 i+1}-x_{2 i+2}\right)\right) \\
\leq \sum_{i=1}^{n}\left(x_{2 i}\left(1-x_{2 i}\right)+\left(1-x_{2 i+2}\right)\right) \\
=\frac{n}{2}-\sum_{i=1}^{n} x_{2 i}^{2} \leq \frac{n}{2}=\frac{n}{4}+\frac{[2]}{2}
\end{array}
$$
In summary, the maximum value of $\sum_{i=1}^{n} x_{i}\left|x_{i}-x_{i+1}\right|$ is $\frac{n}{4}+\frac{\left[\frac{n}{2}\right]}{2}$.