3. Let $n \geq 1$ be a natural number and $a>0$ a given real number. Find the number of solutions $\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ to the equation

$$
\sum_{i=1}^{n}\left(x_{i}^{2}+\left(a-x_{i}\right)^{2}\right)=n a^{2}
$$

such that $x_{i} \in[0, a]$, for $i=1,2, \ldots, n$.
Solution. We will rewrite the given equation in the form

$$
\sum_{i=1}^{n}\left(2 x_{i}^{2}-2 a x_{i}+a^{2}\right)=n a^{2} \Leftrightarrow \sum_{i=1}^{n} x_{i}\left(x_{i}-a\right)=0
$$

Since we are looking for solutions in the interval $[0, a]$, the expressions $x_{i}-a \leq 0$, so accordingly

$$
\begin{gathered}
x_{i}\left(x_{i}-a\right) \leq 0, i=1,2,3,4, \ldots, n . \text { Given the condition } \sum_{i=1}^{n} x_{i}\left(x_{i}-a\right)=0, \text { we get } \\
x_{i}\left(x_{i}-a\right)=0 \text { for } i=1,2,3,4, \ldots, n
\end{gathered}
$$

Accordingly, $x_{i}=0$ or $x_{i}=a, i=1,2,3,4, \ldots, n$. Therefore, the number of solutions is $2^{n}$.