Problem 4. Let $n \geq 2$ be a natural number. Determine the set of values that the sum

$$
S=\left[x_{2}-x_{1}\right]+\left[x_{3}-x_{2}\right]+\ldots+\left[x_{n}-x_{n-1}\right]
$$

can take, where $x_{1}, x_{2}, \ldots, x_{n}$ are real numbers with integer parts $1,2, \ldots, n$.
Solution. Let $a, b \in \mathbb{R}$. Then $[a] \leq a<[a]+1$, from which $-[a]-1<-a \leq -[a]$. Adding with $[b] \leq b<[b]+1$, we get

$$
[b]-[a]-1<b-a<[b]-[a]+1
$$

from which we obtain $[b]-[a]-1 \leq [b-a] \leq [b]-[a] \ldots \ldots \ldots \ldots \ldots \ldots$. . . .

Then $\left[x_{k}\right]-\left[x_{k-1}\right]-1 \leq \left[x_{k}-x_{k-1}\right] \leq \left[x_{k}\right]-\left[x_{k-1}\right]$, from which $0 \leq$ $\left[x_{k}-x_{k-1}\right] \leq 1$, for any $k=2,3, \ldots, n$. As a result, $0 \leq S \leq n-1.2 \mathbf{p}$

We will show that the set of values that $S$ can take is $\{0,1,2, \ldots, n-1\}$.

The maximum value $S=n-1$ is obtained, for example, for $x_{k}=k$, $k=1,2, \ldots, n$ $1 p$

The sum $S=p$, where $0 \leq p \leq n-2$, is obtained, for example, for:

$$
x_{k}= \begin{cases}k+\frac{1}{k+1}, & \text { if } 1 \leq k \leq n-1-p \\ k, & \text { if } n-p \leq k \leq n\end{cases}
$$