I read one theorem in the book, they said there will be exactly $\dfrac{p-1}{2}$ quadratic residues of $p$. So for each $i$, $x^2 \equiv a_i \pmod{p} \text{ where } 1 \leq i \leq p - 1$
But if we sum all $a_i$, then what does this sum equal to? $\sum_{i=1}^{\frac{p-1}{2}}a_i = ?$
I haven't used the condition that $p \equiv 1 \pmod{4}$, so I think I missed one important point here. Any idea?
Update
The original problem
Let $p$ be a prime such that $p \equiv 1 \pmod{4}$.
Prove that the sum of those numbers $1 \leq r \leq p - 1$ that are quadratic residues modulo $p$ is $\dfrac{p(p-1)}{4}$.
Thanks,