Example of multivalued function that attains maximum when values form evenly spaced vector I have four variables $x,y,z,w$, such that $x\ge1,w\le7, x\le y\le z\le w$.
I need to find a function that attains maximum when $x,y,z,w$ are evenly spaced on $[1,7]$, i.e. $(x,y,z,w)=\left(1,3,5,7\right)$ and minimum when all variables are equal.
$(4-(y-x))^2+(4-(z-x))^2+(4-(z-y))^2+(4-(w-x))^2+(4-(w-y))^2+(4-(w-z))^2$ is an example of such function, but depending on values $4-(y-x)$ can be either positive or negative. I need it to be either positive or negative.
Perhaps, somebody knows other examples of such functions or relevant literature.
Thank you in advance.
 A: Consider the variables $(u_1, \dots, u_4) = (x+1, y-x, z-y, w-z)$. These are nonnegative and the maximum should be attained when they are equal. 
There are lots of such functions of $u$, for example
$$\sum_{1\le i<j\le 4} (u_i-u_j)^2$$
or more generally
$$\sum_{1\le i<j\le 4} f(u_i-u_j)$$
for any $f$ that is minimized at $0$. 
There are symmetrization theorems that show that certain quantities are maximized by equally spaced parameters; chapter 4 of this survey is one source of them. 
A: Let $\,g\,$ be a strictly concave and strictly increasing function on $\,[\,0,6\,]\,$ such that $\,g(0)=0\,$.
Define $\,f : \left\{\, (x,y,z,w) \in [\,1,7\,]^4 \;\mid\; x \le y \le z \le w \,\right\} \to \mathbb{R}\,$ as: $$\,f(x,y,z,w) \;=\; g(y-x)+g(z-y)+g(w-z)$$


*

*$f$ is non-negative since so is $g\,$.

*$f(x,y,z,w) \gt 0$ if at least two consecutive variables are unequal since the respective $\,g(\cdot)\,$ term is strictly positive in that case, so $f(x,y,z,w)=0 \;\iff\; x=y=z=w\,$ i.e. the minimum of $\,0\,$ is attained when all variables are equal.

*It follows from Jensen's inequality that the maximum is attained when $y-x=z-y=w-z$ and it follows from monotonicity that it happens when $x=1,w=7$ i.e. at $\,(1,3,5,7)\,$:
$$\require{cancel}
\begin{align}
\displaystyle f(x,y,z,w) \;&=\; g(y-x)+g(z-y)+g(w-z) \\[5px]
 &\le\; 3 \cdot g\left(\frac{(\cancel{y}-x)+(\bcancel{z}-\cancel{y})+(w-\bcancel{z})}{3}\right) \;=\; 3 \cdot g\left(\frac{w-x}{3}\right) \\[5px]
 &\le 3 \cdot g\left(\frac{7-1}{3}\right) = 3\cdot g(2)
\end{align}
$$
An example could be $\,g(x) =\ln(1+x)\,$, but any $\,g\,$ satisfying the given conditions would work. 
