5. Let $n$ be a given positive integer, and the sum
$$
S=\sum_{1 \leqslant i<j \leqslant n}\left|x_{i}-x_{j}\right|\left(0<x_{i}<1, i=1,2, \cdots, n\right) \text {. }
$$

Find the maximum possible value of the sum.
Notice that,
$$
\begin{array}{l}
S=\sum_{k=1}^{n}\left((k-1) x_{k}-(n-k) x_{k}\right) \\
=\sum_{k=1}^{n}\left(x_{k}(2 k-n-1)\right) \\
\leqslant \sum_{k \geq \frac{n+1}{2}}\left(x_{k}(2 k-n-1)\right) .
\end{array}
$$

When $n$ is odd,
$$
\begin{aligned}
S & \leqslant \sum_{k=\frac{n+1}{2}}^{n}\left(x_{k}(2 k-n-1)\right) \\
& \leqslant \sum_{k=\frac{n+1}{2}}^{n}(2 k-n-1) \\
& =\frac{n^{2}-1}{4},
\end{aligned}
$$

When $x_{1}=x_{2}=\cdots=x_{\frac{n-1}{2}}=0, x_{\frac{n+1}{2}}=x_{\frac{n+3}{2}}=\cdots=x_{n}=1$, the equality can be achieved;
When $n$ is even,
$$
\begin{array}{l}
S \leqslant \sum_{k=\frac{n+2}{2}}^{n}\left(x_{k}(2 k-n-1)\right) \\
\leqslant \sum_{k=\frac{n+2}{2}}^{n}(2 k-n-1)=\frac{n^{2}}{4},
\end{array}
$$

When $x_{1}=x_{2}=\cdots=x_{\frac{n}{2}}=0, x_{\frac{n}{2}+1}=x_{\frac{n}{2}+2}=\cdots=x_{n}=1$, the equality can be achieved.

Thus, the maximum possible value is $\left[\frac{n^{2}}{4}\right]$, where $[x]$ denotes the greatest integer not exceeding the real number $x$.