Show that if the equation $a^2 + 1\equiv 0\pmod{p}$ is solvable for some $a$, then $p$ can be represented as a sum of two squares.