$ \sum\limits_{i=1}^{p-1} \Bigl( \Bigl\lfloor{\frac{2i^{2}}{p}\Bigr\rfloor}-2\Bigl\lfloor{\frac{i^{2}}{p}\Bigr\rfloor}\Bigr)= \frac{p-1}{2}$ I was working out some problems. This is giving me trouble.


*

*If $p$ is a prime number of the form $4n+1$ then how do i show that:


$$ \sum\limits_{i=1}^{p-1} \Biggl( \biggl\lfloor{\frac{2i^{2}}{p}\biggr\rfloor}-2\biggl\lfloor{\frac{i^{2}}{p}\biggr\rfloor}\Biggr)= \frac{p-1}{2}$$
Two things which i know are:


*

*If $p$ is a prime of the form $4n+1$, then $x^{2} \equiv -1 \ (\text{mod} \ p)$ can be solved.

*$\lfloor{2x\rfloor}-2\lfloor{x\rfloor}$ is either $0$ or $1$.
I think the second one will be of use, but i really can't see how i can apply it here.

Without giving everything away: when is $\lfloor2x\rfloor - 2\lfloor x\rfloor$ equal to $0$, and when is it equal to $1$?  Can you find some bijection between values of $i$ in your sum that fall into the first camp, and those that fall into the second?  (You may find the other fact you gave to be useful for finding this bijection!)
