Show that if $a$ is any integer not divisible by $p$, then $a^{(p-1)/2}\equiv \pm 1 \pmod p$.
I know one wants to use Fermat's Little Theorem which states if $a$ is any integer not divisible by $p$, then $a^{p-1} \equiv 1 \pmod p$.
I was considering starting off with this and taking the square root of both sides; however, trouble can occur when $a^{(p-1)/2}$ is not a perfect square, and I'm not sure how to handle this.