2. Let $[x]$ denote the greatest integer not exceeding the real number $x$. Suppose $x_{1}, x_{2}, \cdots, x_{n} \in \mathbf{R}$, and $\left[x_{1}\right],\left[x_{2}\right], \cdots,\left[x_{n}\right]$ is a permutation of 1, 2, ..., n, where $n \geqslant 2$ is a given integer. Find the maximum and minimum values of $\sum_{i=1}^{n-1}\left[x_{i+1}-x_{i}\right]$.
2. Since $\left[x_{1}\right],\left[x_{2}\right], \cdots,\left[x_{n}\right]$ is a permutation of $1,2, \cdots, n$, for any $i=1,2, \cdots, n$, we have $1 \leqslant x_{i}x_{i+1}-x_{i}-1$, thus
$$
\begin{array}{l}
S>\sum_{i=1}^{n-1}\left(x_{i+1}-x_{i}-1\right)=x_{n}-x_{1}-(n-1) \\
>-(2 n-1) .
\end{array}
$$

Since $S$ is an integer, we know $S \geqslant 2-2 n$.
Let $x_{i}=i(i=1,2, \cdots, n)$, then
$$
\sum_{i=1}^{n-1}\left[x_{i+1}-x_{i}\right]=n-1 \text {. }
$$

Let $x_{i}=n+1-i+\frac{1}{i+1}(i=1,2, \cdots, n)$, then for any $i=1,2, \cdots, n-1$, we have
$$
\begin{array}{l}
{\left[x_{i+1}-x_{i}\right]} \\
=\left[n+1-(i+1)+\frac{1}{i+2}-\left(n+1-i+\frac{1}{i+1}\right)\right] \\
=\left[-1-\frac{1}{(i+1)(i+2)}\right]=-2 .
\end{array}
$$

Therefore, $\sum_{i=1}^{n-1}\left[x_{i+1}-x_{i}\right]=2-2 n$.
In summary, the maximum value of $\sum_{i=1}^{n-1}\left[x_{i+1}-x_{i}\right]$ is $n-1$, and the minimum value is $2-2 n$.