Sum of values that are equiv to a quadratic residue modulo p where p is a prime. Let $p$ be a prime and define $A$ = sum of all $1 \leq a < p$ such that $a$ is a quadratic residue modulo $p$, and define $B$ = sum of all $1 \leq b < p$ such that $b$ is a non-residue modulo $p$.
Compute $A \pmod{p}$ and $B \pmod{p}$.
So I get $A = B \equiv 0 \pmod{p}$, how would I verify this for all primes $p$? I feel like I'm missing something.
 A: Since $A$ is the sum of all quadratic residues $\pmod{p}$, the sum $\sum_{i = 1}^{g} i^{2}, 1 \leq g \leq \frac{p-1}{2}$. From (d), we can use the fact and plug in so we get:
\begin{align*}
\sum_{i = 1}^{g} i^{2} &= \frac{p^{3} - p}{24} = A\\
&= p\frac{p^{2} - 1}{24}
\end{align*}
$A$ is thus $\equiv 0 \pmod{p}$, unless $p = 2$ or $3$.
A: Apologies to those who think I am doing math falsely! :) I thought that my comment above was a sufficient hint, but it seems not to be. The point is simply that the product of two quadratic residues mod $p$ gives another quadratic residue; also, since $p$ is prime, multiplying by any nonzero class mod $p$ is one-to-one. So as long as $p\neq 2,3$ and with $4$ a our quadratic residue, we find that the set $\{j\mid j \text{is a quadratic residue mod }p\} = \{4j\mid j \text{is a quadratic residue mod }p\}$. So (doing arithmetic mod $p$), $A = 4A$, and if $3$ is invertible, this shows that $A=0$.
Note that not only does this approach not work for $p=2$ or $3$, one calculates directly in both cases that $A=1 \neq 0$.
A: for any odd prime, we know that we've half values QR and half QNR. So if p=3(mod)${QR=\{a_1,a_2,...,a_n}\}$, then ${QNR=\{-a_1,-a_2,...,-a_n}\}$, so their algebraic sum is ${0}$. or if p=1(mod4) then ${QR=\{a_1,-a_1,...,a_k,-a_k}\}$, and ${QNR=\{b_1,-b_1,...,b_m,-b_m}\}$

for ex. p=11 (3 (mod4)) then ${QR=\{1,4,9,5,3}\}$, and ${QNR=\{10,7,2,6,8}\}$ ${\equiv \{\ -1,-4,-9-5-3\} }$,   hence sum of elements of QR+ elements of QNR=${0}$

in case of p=13 (1 (mod4)), we have ${QR=\{1,4,3,9,12,10\}=\{1,4,3,-4,-1,-3\}}$
same way ${QNR=\{2,5,6,7,8,11\}=\{2,5,6,-6,-5,-2\}}$ and their sum is ${0}$.
