Question 6
Let $n$ be a fixed positive integer. To any choice of $n$ real numbers satisfying
$$
0 \leq x_{i} \leq 1, \quad i=1,2, \ldots, n
$$
there corresponds the sum
(*)
$$
\begin{aligned}
& \sum_{1 \leq i\lt j \leq n}\left|x_{i}-x_{j}\right| \\
& \qquad \begin{aligned}
= & \left|x_{1}-x_{2}\right|+\left|x_{1}-x_{3}\right|+\left|x_{1}-x_{4}\right|+\cdots+\left|x_{1}-x_{n-1}\right|+\left|x_{1}-x_{n}\right| \\
& \quad+\left|x_{2}-x_{3}\right|+\left|x_{2}-x_{4}\right|+\cdots+\left|x_{2}-x_{n-1}\right|+\left|x_{2}-x_{n}\right| \\
& \quad+\left|x_{3}-x_{4}\right|+\cdots+\left|x_{3}-x_{n-1}\right|+\left|x_{3}-x_{n}\right| \\
& \quad+\cdots+\left|x_{n-2}-x_{n-1}\right|+\left|x_{n-2}-x_{n}\right| \\
& \quad+\left|x_{n-1}-x_{n}\right| .
\end{aligned}
\end{aligned}
$$
Let $S(n)$ denote the largest possible value of the sum (*). Find $S(n)$.
$$
0 \leq x_{i} \leq 1, \quad i=1,2, \ldots, n
$$
there corresponds the sum
(*)
$$
\begin{aligned}
& \sum_{1 \leq i\lt j \leq n}\left|x_{i}-x_{j}\right| \\
& \qquad \begin{aligned}
= & \left|x_{1}-x_{2}\right|+\left|x_{1}-x_{3}\right|+\left|x_{1}-x_{4}\right|+\cdots+\left|x_{1}-x_{n-1}\right|+\left|x_{1}-x_{n}\right| \\
& \quad+\left|x_{2}-x_{3}\right|+\left|x_{2}-x_{4}\right|+\cdots+\left|x_{2}-x_{n-1}\right|+\left|x_{2}-x_{n}\right| \\
& \quad+\left|x_{3}-x_{4}\right|+\cdots+\left|x_{3}-x_{n-1}\right|+\left|x_{3}-x_{n}\right| \\
& \quad+\cdots+\left|x_{n-2}-x_{n-1}\right|+\left|x_{n-2}-x_{n}\right| \\
& \quad+\left|x_{n-1}-x_{n}\right| .
\end{aligned}
\end{aligned}
$$
Let $S(n)$ denote the largest possible value of the sum (*). Find $S(n)$.