Q:

Proof of $a^{\frac{p-1}{2}} \equiv \left(\frac{a}{p}\right)$ mod $p$

$p$ is a prime, odd integer. $a$ is an integer. we assume that $p$ does not divide $a$. $\left( \frac{a}{p} \right)$ denotes the Legendre symbol.
In order to prove $a^{\frac{p-1}{2}} \equiv \left(\frac{a}{p}\right)$ mod $p$ my course 
demonstrates the following statement first (Wilson) :
$\left( p-1 \right)! \equiv -\left(\frac{a}{p}\right) a^{\frac{p-1}{2}}$ mod $p$
However it is not clear to me how this implies the first statement.

A:

Hint: Use Wilson's theorem $(p - 1)! \equiv -1 \bmod p$ and the property $\left(\frac{a}{p}\right)^2 = 1$.

