Under what condition on the prime number $p$ does there exist an integer $a$ such that $a^{2} \equiv-1(\bmod p)$?
First proof: We group by equivalence class where $y x$ if and only if $y=-x, y=x, y=-1/x, y=1/x$. 1 and -1 form a class of size 2, and the possible roots of -1 would form a second class of size 2. All other classes are of size 4, and the sum of their sizes is $p-1$, so if and only if $p=1[4]$ or $p=2$, we can find a square root of -1. Second proof: Lemma $x$ is a square $\bmod p$ if and only if $x^{(p-1)/2}=1$. For the necessary condition, we use Fermat's little theorem on $a^2=x$. For the sufficient condition, we consider $X^{(p-1)/2}-1$ as a polynomial in $\mathbb{Z}/p\mathbb{Z}$, it has at most $(p-1)/2$ roots, and the squares are roots, and there are exactly $(p-1)/2$ squares (we group integers in pairs, if $p \mid a^2-b^2$ then $a=b[p]$ or $a=-b[p]$), which concludes the lemma. We apply it to $-1^{(p-1)/2}$ and we get the same conclusion as with the first proof.