Prove that $\left( \frac{p-1}{2} \right)! \equiv (-1)^n \mod p$, $n$ is quad. nonres. of $p$ $< p/2$. Let $p$be a prime number with $p \equiv 3 \mod 4$. Prove that $\left( \frac{p-1}{2} \right)! \equiv (-1)^n \mod p$ where $n$ is the number of positive integers less than $p/2$ that are quadratic nonresidues of $p$.
I have tried solving this problem using the fact that $\left( \frac{p-1}{2}\right)! \equiv \pm 1 \mod p$ if and only if $p \equiv 3 \mod 4$. But I can't seem to bring the logic with the $n$ into the picture. Can you help?

You can write
$$1 \equiv \left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv \prod_{k=1}^{\frac{p-1}{2}}k^2.$$
Now write the squares $> \frac{p-1}{2}$ as $k^2 = p-r$ with $r \leqslant \frac{p-1}{2}$. Count the $-1$s.
