Solution
= Solution
Write $\chi(a)=(\frac ap)$. When $p\equiv1\pmod4$, the <first supplementary law for quadratic reciprocity> gives $\chi(-1)=1$, so $\chi(p-a)=\chi(a)$. Pairing $a$ with $p-a$ gives
$$
T=p\sum_{a=1}^{(p-1)/2}\chi(a).
$$
The sum of the nontrivial character $\chi$ over all nonzero residue classes is zero. Because its two half-sums are equal when $\chi(-1)=1$,
$$
0=\sum_{a=1}^{p-1}\chi(a)
=2\sum_{a=1}^{(p-1)/2}\chi(a).
$$
Hence
$$
\boxed{T=0.}
$$