How find this maximum and minimum of the value $\sum_{i=1}^{n-1}[x_{i+1}-x_{i}]$ Question:

let $x_{1},x_{2},\cdots,x_{n}\in \mathbb{R}$,and Assume that the following two sets are equivalent;
$$\{[x_{1}],[x_{2}],[x_{3}],\cdots,[x_{n}],\}=\{1,2,3,\cdots,n\},n\ge 2 $$
Find the maximum and minimum of
$$\sum_{i=1}^{n-1}[x_{i+1}-x_{i}]$$

where $[x]$ is is the biggest integer not greater than $x$.
My idea: since I consider simple  case
when $n=2$, then
$$\{[x_{1}],[x_{2}]\}=\{1,2\}$$
then it is clear
$$[x_{1}-x_{2}]_{min}=-2$$
$$[x_{1}-x_{2}]_{max}=1$$
and for general I can't solve it.Thank you
 A: $\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
$To begin with I am going to restate the question, for two reasons.
First, the greatest integer less than or equal to $x$ is known as the floor of $x$
and is nowadays written $\floor{x}$;
you'll see the notation $[x]$ only in older mathematical literature.
Besides that, you should always strive to formulate clearly whatever mathematics
you are communicating.
It seems you did not put enough time into writing your question.
Can you afford to spend just five minutes more? A couple of minutes?
Your question is:

Let $x_1$, $x_2$, $\ldots$, $x_n$ ($n\geq 2$) be real numbers such that
  $$
\{\floor{x_1},\floor{x_2},\ldots,\floor{x_n}\}
    \:=\: \{1,2,\ldots,n\}~. \tag{1}
$$
  Find the maximum and the minimum of
  $$
\sum_{i=1}^{n-1}\floor{x_{i+1}-x_i}~.
$$

The plan of solution: first we shall determine an upper and a lower bound
for the sum in question, denote it by $S$;
then, with these two bounds in hand, we shall prove that they are in fact
the maximum and the minimum.
$\newcommand{\fracpart}[1]{\left\langle#1\right\rangle}
$Given a real number $x$, let $\fracpart{x}$ denote the fractional part of $x$,
defined by $\fracpart{x} := x-\floor{x}$. Always $0\leq{\fracpart{x}}<1$.
(The accepted notation for the fractional part of $x$ is $\{x\}$;
we won't use it here so as not to confuse it with the notation for sets.)
The sum $S$ can be rewritten as
$$
S \:=\: \sum_{i=1}^{n-1}\,(x_{i+1}-x_i) - \sum_{i=1}^{n-1}\fracpart{x_{i+1}-x_i}
    \:=\: x_n-x_1 - \sum_{i=1}^{n-1}\fracpart{x_{i+1}-x_i}.
$$
Since $1\leq x_1,\,x_n<n+1$ we have $-n<x_n-x_1<n$,
and since $0\leq\sum_{i=1}^{n-1}\fracpart{x_{i+1}-x_i}<n-1$,
it follows that $-2n+1<S<n$.
But $S$ is an integer, thus
$$
-2(n-1) \:\leq\: S \:\leq\: n-1~. \tag{2}
$$
Choosing $x_i=i$, $1\leq i\leq n$, we get $S=n-1$.
Choosing $x_i=n+1-i+\theta_i$, $1\leq i\leq n$,
for some real numbers $\theta_i$ satisfying the inequalities
$1>\theta_1>\theta_2>\cdots>\theta_n\geq0$
(for example,
the numbers $\theta_i=1-i/n$, $1\leq i\leq n$, fit the bill),
we have $\floor{x_{i+1}-x_i}=-2$ for $1\leq i\leq n-1$,
so in this case we get $S=-2(n-1)$.
The answer is: the maximum value of $S$ is $n-1$,
while the minimum value of $S$ is $-2(n-1)$.
Remarks. $~$The suggestion of Macavity
that one needs seek the minimum and the maximum only over
integers $x_i$ is wrong:
the maximum $n-1$ can be attained by choosing $x_i=i$, $1\leq i\leq n$,
but the minimum $-2(n-1)$ is unattainable.
Indeed, if every $x_i$ is an integer,
then $\floor{x_{i+1}-x_i}=x_{i+1}-x_i$ for $1\leq i\leq n-1$,
thus $S=x_n-x_1\geq -(n-1)>-2(n-1)$.
$\qquad$If you have carefully read the solution, you have surely noticed that the only
property of the numbers $x_1$, $x_2$, $\ldots$, $x_n$ we have used
to derive the bounds $(2)$ for $S$ was $$|x_n-x_1|<n \tag{3}~.$$
Thus the maximum and the minimum of $S$ remain the same if the $x_i$'s
are constrained by the weaker condition $(3)$ instead of the condition $(1)$.
