Hard inequality and number theory Let $m,n \in \mathbb{N}$ and $m \geq n \geq 2$ and $x_1,x_2,...x_n \in \mathbb{N}_{\geq 1}$ such as $x_1+x_2+...+x_n=m$.
Find $\min P$ with $P= \sum_{i=1}^{n} x_i^2.$
 A: This is a low-tech explanation of Joe Silverman's comment (but see also Geoff Robinson's response). 
Proposition. The minimum is attained when the variables differ by at most $1$, i.e. when each $x_i$ is either $\lfloor m/n\rfloor$ or $\lceil m/n\rceil$. 
Proof. If $x_i-x_j\geq 2$, say, then replacing $x_i$ (resp. $x_j$) by $x_i-1$ (resp. $x_j+1$) yields a better $n$-tuple, because
$$(x_i-1)+(x_j+1)=x_i+x_j\qquad\text{but}\qquad (x_i-1)^2+(x_j+1)^2<x_i^2+x_j^2.$$
Remark. Note that the proposition determines a unique $n$-tuple for the minimum, namely the number of $\lfloor m/n\rfloor$'s and $\lceil m/n\rceil$'s is determined by the residue of $m$ modulo $n$.
A: It is hard to find a precise answer, since there are some choices of $m,n$ which are easier than others . 
   Lagrange's identity gives
$\left( \sum_{i} x_{i}\right)^{2} +
\sum_{i<j} (x_i -x_j)^{2} =
n P$, which is relevant.
A: This is a quadratic integer linear programming problem, see this 2014 paper (by Christian Bliekú, Pierre Bonami
, and Andrea Lodi) for a survey of what is known. (this problem is positive definite, so not as hard as the hardest case).
