Let $p$ be a prime with $p \equiv 3\pmod{4}$. Find the remainder of $\sum_{i=1}^{p-1}\big(\frac{i^4+1}{p}\big)$ divided by $p$. Let $p$ be a prime with $p \equiv 3\pmod{4}$. Find the remainder of $$\sum_{i=1}^{p-1}\Big(\frac{i^4+1}{p}\Big)$$ divided by $p$. Here $\big(\frac{i^4+1}{p}\big)$ denotes the Legendre symbol. 
I know that if $p-1\nmid k$, then $\sum_{i=1}^{p-1}i^k\equiv 0\pmod{p}$. And what should I do next?
 A: We have $\big(\frac{a}{p}\big)\equiv a^{(p-1)/2}\pmod{p}$. Denoting $q=(p-1)/2$ and using the binomial formula, we get $$\sum_{a=1}^{p-1}\Big(\frac{a^4+1}{p}\Big)\equiv\sum_{k=0}^{q}\binom{q}{k}\sum_{a=1}^{p-1}a^{4k}\pmod{p}.$$ The inner sum is $\not\equiv 0\pmod{p}$ if and only if $(p-1)\mid 4k$, that is, $k=0$ or $k=q$; in both of these cases, it is $-1\pmod{p}$, thus the whole sum is $-2\pmod{p}$.  The answer is $\color{blue}{p-2}$.
[The sum itself is equal to $-2$ since it's the sum of $p-1$ elements of $\{-1,1\}$.]
A: We prove that the sum is $-2$. 
The set of nonzero quadratic residues mod $p$ forms a cyclic group of order $(p-1)/2$ generated by $g^2$ where $g$ is a primitive root mod $p$. And $(p-1)/2$ is an odd number. Thus, the mapping $i\mapsto i^2$ is a bijection on the set of nonzero quadratic residues.
Then we have
$$
\sum_{a=1}^{p-1} \left( \frac{a^4+1}p \right) = \sum_{a=1}^{p-1}\left( \frac{a^2+1}p \right)=\sum_{a=1}^{p-1} \left(1+\left(\frac ap\right)\right)\left( \frac{a+1}p\right). 
$$
The last sum can be evaluated to $-2$ via the well-known trick of using 
$$\left(\frac ap\right)=\left(\frac{\overline{a}}p\right)$$
where $\overline{a}$ is the inverse of $a$ mod $p$. 
