Showing $x_n-x_nx_1+\sum_{k=1}^{n-1} (x_k-x_kx_{k+1})\leq\left\lfloor\frac{n}{2}\right\rfloor$, with $x_i\in[0,1]$ 
Let $x_1, x_2,\ldots, x_n$ be arbitrary numbers from the interval $[0,1]$ with $n>1$.
Show that $$x_n-x_nx_1+\sum_{k=1}^{n-1} (x_k-x_kx_{k+1})\leq\left\lfloor\frac{n}{2}\right\rfloor$$

I tried to factor out the $x_k$ from each term to show that if the coefficient $x_k$ of $x_k(1-x_{k+1})$ is larger than $\dfrac{1}{2}$, then the term $x_{k-1}(1-x_k)$ must be smaller than $\dfrac12$, but I don't know where to go from here or if it is even the right approach.
 A: Use $\mod n$ for subscripts and call the expression you want to maximize $X$.
If $2\mid n$, by simple transformation,
\begin{align*}X={}&\sum_{k=1}^n\left(\frac{a_k}2-a_ka_{k+1}+\frac{a_{k+1}}2\right)\\[2pt]={}&\sum_{k=1}^n\left(-\frac{\left(2a_k-1\right)\left(2a_{k+1}-1\right)-1}4\right).\end{align*}
Since $2a_k-1$ and $2a_{k+1}-1\in[-1,1]$, each term of the sum $\le\dfrac12$. So $X\le\dfrac n2=\left\lfloor\dfrac n2\right\rfloor$.
If $2\nmid n$, notice that $X$ is a linear function of $a_n$, so maximum is reached at $a_n=0$ or $1$. If $a_n=0$, also $a_1a_n=0$, then
\begin{align*}X={}&\sum_{k=1}^{(n-1)/2}\left(a_{2k-1}+a_{2k}-a_{2k-1}a_{2k}-a_{2k}a_{2k+1}\right)\\[2pt]\le{}&\sum_{k=1}^{(n-1)/2}\left(a_{2k-1}+a_{2k}-a_{2k-1}a_{2k}\right)\\[2pt]={}&\sum_{k=1}^{(n-1)/2}\left(1-(1-a_{2k})(1-a_{2k-1})\right)\\[2pt]\le{}&1\cdot\frac{n-1}2=\frac{n-1}2=\left\lfloor\frac n2\right\rfloor.\end{align*}
If $a_n=1$, then $a_1a_n$ cancels with $a_1$. So
\begin{align*}X={}&\sum_{k=1}^{(n-1)/2}\left(a_{2k}+a_{2k+1}-a_{2k-1}a_{2k}-a_{2k}a_{2k+1}\right)\\[2pt]\le{}&\frac{n-1}2=\left\lfloor\frac n2\right\rfloor.\end{align*}
This inequality can be proved by a nearly identical method with the one demonstrated in the last case.
A: *This is not an official answer.
Edit
I apologise for my inconsistency in my previous answer, hence its been removed. While, this question already has an accepted answer/correct answers, this method serves to confirm the answers/inequality.

The following are for $n = 2,3,4$ respectively and display the inequality approaching values $[0, $floor$(\frac{n}{2})]$ but never exceed  floor$(\frac{n}{2})$ computationally. Higher values of $n$ were not computed as they pose time restrictions in computation due to probability restrictions.
$n = 2$" />
$n = 3$" />
$n = 4$" />
A: When $n$ is even, we have
\begin{align*}
 x_1(1-x_2) + x_2(1-x_3) 
 = 1 - (1 - x_1)(1 - x_2) - x_2 x_3 &\le 1,\\
 x_3(1-x_4) + x_4(1 - x_5) = 1 - (1-x_3)(1-x_4) - x_4x_5 &\le 1,\\
 \cdots \cdots \cdots \cdots &\qquad\\
 x_{n-1}(1 - x_n) + x_n(1 - x_1)
 = 1 - (1 - x_{n-1})(1 - x_n) - x_nx_1 &\le 1.
\end{align*}
Adding them up, the desired result follows.
When $n$ is odd, we split into two cases:
If $1 - x_1 - x_{n-1} \ge 0$, then
\begin{align*}
 x_2(1 - x_3) + x_3(1-x_4) = 1 - (1-x_2)(1-x_3) - x_3x_4 &\le 1, \\
 x_4(1-x_5) + x_5(1-x_6) = 1 - (1-x_4)(1-x_5) - x_5x_6 &\le 1,\\
  \cdots \cdots \cdots \cdots &\qquad\\
 x_{n-3}(1-x_{n-2}) + x_{n-2}(1-x_{n-1}) = 1 - (1-x_{n-3})(1-x_{n-2}) - x_{n-2}x_{n-1} &\le 1,
\end{align*}
and
\begin{align*}
 &x_{n-1}(1 - x_n) + x_n(1-x_1) + x_1(1-x_2)\\
 ={}& (1 - x_1 - x_{n-1})x_n + x_{n-1} + x_1(1-x_2)\\
 \le{}& (1-x_1-x_{n-1}) + x_{n-1} + x_1(1-x_2)\\
 ={}&1 - x_1x_2\\
 \le{}& 1. 
\end{align*}
Adding them up, the desired result follows.
If $1 - x_1 - x_{n-1} < 0$, then
\begin{align*}
 x_1(1-x_2) + x_2(1-x_3) 
 = 1 - (1 - x_1)(1 - x_2) - x_2 x_3 &\le 1,\\
 x_3(1-x_4) + x_4(1 - x_5) = 1 - (1-x_3)(1-x_4) - x_4x_5 &\le 1,\\
 \cdots \cdots \cdots \cdots &\qquad\\
 x_{n-4}(1 - x_{n-3}) + x_{n-3}(1 - x_{n-2})
 = 1 - (1 - x_{n-4})(1 - x_{n-3}) - x_{n-3}x_{n-2} &\le 1,
\end{align*}
and
\begin{align*}
 &x_{n-2}(1 - x_{n-1}) + x_{n-1}(1 - x_n) + x_n(1 - x_1)\\
 ={}& x_{n-2}(1 - x_{n-1}) + x_{n-1} + x_n( 1 - x_1 - x_{n-1})\\
 \le{}& x_{n-2}(1 - x_{n-1}) + x_{n-1} \\ 
 \le{}& (1 - x_{n-1}) + x_{n-1}\\
 ={}& 1.
\end{align*}
Adding them up, the desired result follows.
We are done.
A: If $x_2, x_3, \ldots, x_n$ are fixed, then the expression is a linear function in $x_1$ with coefficient $(1 - x_2 - x_n)$. The expression achieves it's maximum at:
$$\begin{cases} 1 & x_2 + x_n < 1   \\
0 & x_2 + x_n > 1 \\
[0,1] & x_2 + x_n = 1 \\ \end{cases}$$
In the last case, since choosing any value doesn't change the expression, we may set it to take on the value of $1$.
Applying this similarly across all variables, the expression achieves (one of) its maximum when
$$x_i = \begin{cases} 1 & x_{i+1} + x_{i-1} \leq 1   \\
0 & x_{i+1} + x_{i-1} >  1 \\
 \end{cases}$$
Investigating this characterization further:

*

*We cannot have $1-1-1$ as the middle will be $0$. So no 3 consecutive 1's.

*We cannot have $0-0-0$ or $0-0-1$ as the middle will be $1$. So no 2 consecutive 1's.

*Thus, the sequence must be formed by (taking cyclic permutations of) chaining together links of the form $0-1$ or $0-1-1$. In particular, after a link, the next number must be 0.

*This allows us to calculate $x_i - x_i x_{i+1}$ easily:

*

*If $(x_i, x_{i+1} ) = (0,1)$, then $ x_i - x_ix_{i+1} + x_{i+1} - x_{i+1} x_{i+2} = 0 - 0 + 1 - 0 = 1 $.

*If $(x_i, x_{i+1}, x_{i+2} ) = (0,1, 1)$, then $ x_i - x_ix_{i+1} + x_{i+1} - x_{i+1} x_{i+2} + x_{i+2} - x_{i+2}x_{i+3} = 0 - 0 + 1 - 1 + 1 - 0 = 1 $.



*Hence, the expression is at most $ \lfloor \frac{n}{2} \rfloor$.

*Furthermore, equality holds iff we (take cyclic permutations of) chain together several $0-1$'s, with 1 $0-x-1$ only if $n$ is odd (where $x$ is any value -> This is the only time that $x_{i-1} + x_{i+1} = 1$)

