In fact, there are several same questions, but I still post it here:
If $(a,p)=1$, $p$ an odd prime, then $\sum_{n=1}^{p}\left(\frac{n^2+a}{p}\right)=-1$.
In those same posts, I tried to read the proof https://artofproblemsolving.com/community/c146h150500p849406 and Number Theory: Solutions of $ax^2+by^2\equiv1 \pmod p$. But I cannot understand the full proof. Instead, I was stuck in some way. Right now, I am trying to use "Eulers' Criterion" to do this question: $\left(\frac{n^2+a}{p}\right)\equiv (n^2+a)^{\frac{p-1}{2}}$ (mod $p$), thus: $\sum_{n=1}^{p}\left(\frac{n^2+a}{p}\right)\equiv \sum_{n=1}^{p}(n^2+a)^{\frac{p-1}{2}}$ (mod $p$).
Then, I tried to apply the binomial expansion to further simplify. And that is the step where I was stuck. Can anyone further explain the mechanism?