2. Note that, if $\displaystyle p\equiv{1}(\bmod.4)$ then $\displaystyle -1$ is a qudratic residue, hence $\displaystyle \left(\tfrac{k}{p}\right)_L=\left(\tfrac{p-k}{p}\right)_L$ ( Legendre's Symbol)
Thus we find that $\displaystyle 2S=\sum_{0\leq k<p;\left(\tfrac{k}{p}\right)_L=1} k+\sum_{0<k<p;\left(\tfrac{k}{p}\right)_L=1} (p-k) = \sum_{0<k<p;\left(\tfrac{k}{p}\right)_L=1} {p}$. - the sum is taken over the quadratic residues-