Let $p$ be a prime. Prove that if $p\equiv 3\pmod{4}$ then the sum$$S=\sum_{i=0}^{p-1}\left(\frac{i^3+6i^2+i}{p}\right)=0$$What is the value of the sum $S$ when $p\equiv 1\pmod{4}$? When $p\equiv 3\pmod{4}$ all i know is that $(-1|p)=-1$ but i am not sure if that gives me anything.