Suppose $Y(f)$ denotes the number of mutually incongruent solutions $(x,y)$ of the congruence $y^2\equiv f(x)\pmod{p}$ ($p$ an odd prime), where $f(x)$ is a polynomial with integral coefficients. Prove that $$Y(f)=p+\sum_{n=0}^{p-1}\left(\dfrac{f(n)}{p}\right).$$ Note: Two solutions $(x_1,y_1)$ and $(x_2,y_2)$ are said to be mutually incongruent if either $x_1\neq x_2$ or $y_1\neq y_2\pmod{p}$, or both.
My attempt:
$p+\sum\limits_{n=0}^{p-1}\left(\dfrac{f(n)}{p}\right)=\sum\limits_{n=0}^{p-1} \left(1+({{f(x)}\over p})\right)=\sum\limits_{n=0}^{p-1} c(x)$
Now $c(x)=0$ if $f(x)$ is not a square mod $p$, it is 1 if $f(x)\equiv 0\pmod{p}$ and it is 2 if $f(x)$ is a nonzero square mod $p$. I don't know whether this can be equal to $Y(f)$? Could someone help me? Thanks in advance.
PS: I also found this link but it does not answer me!