Show that if $p$ is and odd prime and $h$ is an integer, $1\le h \le p$, then
$$\displaystyle\sum_{n=1}^{p}\left(\sum_{m=1}^{h}\left(\frac{m+n}{p}\right)\right)^2=h(p-h)$$ where $\left(\frac{m+n}{p}\right)$ denotes the Jacobi symbol.
My solution:
For $h=1$, we have $\left(\frac{1+n}{p}\right)^2$ is always 1 or 0. It is 0 only when $n=p-1$. So the sum comes out to be $p-1$, which is accordance with $h(p-h)$. Similarly, for $h=p$, and the sum is zero.
But I am having trouble when $ h \neq 1 or p$, how will I proceed in that case?
This question has been taken from the book : An introduction to theory of numbers by Niven, Zuckerman, Montgomery. Section 3.3., question 19. Thanks in advance.