<s>[INST] $p$ divides the sum of the quadratic residues $\bmod p$ Could you help me at the following exercise?
Show that, if $p>3$ is a prime,then $p$ divides the sum of the quadratic residues $\bmod p$.
 [/INST] Let $S$ be the sum of the quadratic residues. As $k$ runs from $1$ to $p-1$, the number $k^2$ runs (twice) over the quadratic residues modulo $p$. Thus
$$2S\equiv 1^2+2^2+\cdot +(p-1)^2.$$
By using the formula for the sum of the first $n$ consecutive squares, we find that
$$2S\equiv \frac{(p-1)(p)(2p-1)}{6}\pmod{p},$$
and therefore 
$$12S\equiv (p-1)(p)(2p-1)\pmod{p}.$$
Since $p$ divides $(p-1)(p)(2p-1)$ but $p\gt 3$, it follows that $p$ divides $S$.
Another way: Let $g$ be a primitive root of $p$. Then the quadratic residues are congruent, modulo $p$, to $g^2,g^4,\dots, g^{p-1}$. Thus if $S$ is the sum of the quadratic residues, we have
$$S\equiv g^2+g^4+\cdots +g^{p-1}\pmod{p}.$$
Multiply both sides by $g^2-1$. We get
$$(g^2-1)S\equiv g^2(g^{p-1}-1)\pmod{p}.$$
By Fermat's Theorem, the right-hand side is congruent to $0$ modulo $p$. And if $p\gt 3$, then $g^2\not\equiv 1\pmod{p}$, and therefore $S\equiv 0\pmod{p}$. 
</s>