How find the maximum of the value $x^2_{1}+x^2_{2}+\cdots+x^2_{2014}$ Question:

let $x_{i}\in[-11,5],i=1,2,\cdots,2014$,and such
  $$x_{1}+x_{2}+\cdots+x_{2014}=0$$
  find the maximum of the value
  $$x^2_{1}+x^2_{2}+\cdots+x^2_{2014}$$

since
$$(x_{i}-5)(x_{i}+11)\le 0$$
then
$$x^2_{i}\le -6x_{i}+55$$
so
$$x^2_{1}+x^2_{2}+\cdots+x^2_{2014}\le -6(x_{1}+\cdots+x_{n})+55\cdots 2014=2014\cdot 55$$
But I find this is not maximum the value,because Now I found this inequality can't equalient,
idea 2： let $$x_{i}+3=a_{i}\in[-8,8]$$
then
$$a_{1}+a_{2}+\cdots+a_{2014}=x_{1}+x_{2}+\cdots+x_{2014}+3\times 2014=6042$$
and then we 
$$\sum_{i=1}^{2014}x^2_{i}=\sum_{i=1}^{2014}(a_{i}-3)^2=\sum_{i=1}^{2014}a^2_{i}-6\sum_{i=1}^{2014}a_{i}+9\cdot 2014=\sum_{i=1}^{2014}a^2_{i}-18126$$
so How find it? Thank you
 A: We want to maximize a continuous function on a compact set, so the maximum surely is attained.
Let $(x_1,\ldots,x_{2014})$ be a point that maximizes the target function.
If there are two indices $i\ne j$ with $x_i,x_j\notin\{-11,5\}$, then $x_i^2+x_j^2$ can be increased to $(x_i+h)^2+(x_j-h)^2=x_i^2+x_j^2+2h^2+2h(x_i-x_j)>x_i^2+x_j^2$ (if $|h|$ is small enough and $h$ has the same sign as $x_i-x_j$  - or arbitrary sign if $x_i=x_j$).
Therefore, we can conclude that at most one coordinate is not on the boundary. So we have $m$ times $-11$, i.e. wlog $x_1=\ldots=x_m=-11$, then $2013-m$ times $5$, i.e. wlog. $x_{m+1}=\ldots=x_{2013}=5$, and one remaining value $x_{2014}=m\cdot11-(2013-m)\cdot 5=16m-10065$. For this to be $\in[-11,5]$, we need $m=629$, which makes $x_{2014}=-1$.
So the target value is 
$$629\cdot(- 11)^2+1384\cdot 5^2 +(-1)^2.
$$
A: Another way - as the objective function is convex, at maximum we must have $n-1$ of the $x_i \in \{-11, 5\}$.  So let $k$ of the variables be $-11$ and the remaining $2013-k$ be $5$ at maximum.  We then have the constraint
$$-11k + 5(2013-k)+x_{2014}=0 \implies x_{2014} = 16k-10065$$
So the objective function is $121k+25(2013-k)+(16k-10065)^2$, which gets maximised when $k=629$ and has a maximum value $110710$. 
