<s>[INST] Maximize $x_1^3+x_2^3+\cdots + x_n^3$ This is from a Brazilian math contest for college students (OBMU):
Given a positive integer $n$, find the maximum value of 
$$x_1^3+x_2^3+ \cdots + x_n^3$$
where $x_j$ is a real number for all $j \in \{1,2,\cdots, n\}$ such that $x_1 + x_2 + \cdots + x_n  = 0$ and $x_1^2 + x_2^2 + \cdots + x_n^2 = 1$ .
 [/INST] I come up with a solution using Lagrange Multipliers (one of the comments and one of answers suggests to use this). First, we need to realize that the domain
$$ S =\{ (x_1,x_2,\cdots,x_n) \in {\mathbb{R}}^n | x_1 + x_2 + \cdots + x_n = 0 \text{ and } x_1^2 + x_2^2 + \cdots + x_n^2 = 1\} $$
is closed (since the functions $(x_1,x_2,\cdots,x_n ) \mapsto x_1 + x_2 + \cdots + x_n$ and $(x_1,x_2,\cdots,x_n ) \mapsto x_1^2 + x_2^2 + \cdots + x_n^2$ are continuous) and bounded (since $x_1^2 + x_2^2 + \cdots + x_n^2 = 1$). Then S is compact.
Define
$$f(x_1,x_2,\cdots,x_n ) = x_1^3 + x_2^3 + \cdots+ x_n^3 $$
$$g(x_1,x_2,\cdots,x_n ) = x_1^2 + x_2^2 + \cdots+ x_n^2 -1 $$
$$h(x_1,x_2,\cdots,x_n ) = x_1 + x_2 + \cdots+ x_n $$
Since $S$ is compact and $f$ is continuous, then $f$ reaches a maximum value in
$S$. We can find the maximum using Lagrange Multipliers:
$$\nabla f = \lambda_1 \nabla g + \lambda_2 \nabla h$$
Thus,
$$ 3(x_1^2,x_2^2,\cdots,x_n^2) = 2\lambda_1(x_1,x_2,\cdots,x_n ) + \lambda_2(1,1,\cdots,1)$$
Then,
$$3x_i^2 = 2\lambda_1 x_i+ \lambda_2 \text{  } \forall i \in \{1,2,\cdots,n\} \label{1}\tag{1}$$
If we add all the equations and use the constraints equations, we obtain $\lambda_2= \frac{3}{n}$. Then,
$$3x_i^2 = 2\lambda_1 x_i+ \frac{3}{n} $$
Solving for $x_i$, we obtain
$$ x_i = \frac{\lambda_1 \pm \sqrt{\lambda_1^2 + \frac{9}{n}}}{3} $$
Let $k$ be a natural number less or equal to $n$. Therefore we can suppose
$$ x_i = \frac{\lambda_1 + \sqrt{\lambda_1^2 + \frac{9}{n}}}{3} \forall i \in \{1,2,\cdots,k\}$$
$$ x_i = \frac{\lambda_1 - \sqrt{\lambda_1^2 + \frac{9}{n}}}{3} \forall i \in \{k+1,k+2,\cdots,n\}$$
Firtly, notice that $k$ is different of $0$ and $n$, because of the constraint $x_1+ x_2 + \cdots + x_n =0$. Using the constraint $x_1^2 + x_2^2 + \cdots + x_n^2 = 1$ and after some simplifications, we obtain
$$\lambda_1 \left(n\lambda_1 + (2k-n) \sqrt{\lambda_1^2 + \frac{9}{n}} \right) = 0\label{2}\tag{2}$$
And using $x_1+ x_2 + \cdots + x_n =0$, we get 
$$ n\lambda_1 + (2k-n) \sqrt{\lambda_1^2 + \frac{9}{n}} = 0 \label{3}\tag{3}$$
So, we just need to satisfy \ref{3}, because with that \ref{2} is automatically satisfied. Then, we get 
$$\lambda_1 = \frac{3(n-2k)}{2\sqrt{(n-k)nk}} $$
Notice that we should consider the other solution with the other sign, but in the end we obtain the same maximum value for both cases. Multiplying \ref{1} by $x_i$:
$$ 3x_i^3 = 2\lambda_1x_i^2 + \frac{3x_i}{n} $$
Adding in all i's:
$$3f = 2\lambda_1 $$
Thus, 
$$ f(k) = \frac{n-2k}{\sqrt{(n-k)nk}} = \frac{1}{\sqrt{n}}\left(\sqrt{\frac{n-k}{k}}-\sqrt{\frac{k}{n-k}}\right)$$
Remember that $k \in {2,3,\cdots, n-1}$. Making $x = \sqrt{\frac{k}{n-k}}$ and analyzing the derivative of 
$$y: (0,1) \rightarrow \mathbb{R}$$
$$ x \mapsto\frac{1}{x}-x $$
We see that the maximum value of $f$ is when $k=1$, that is,
$$ \frac{n-2}{\sqrt{(n-1)n}} $$
</s>