For $n$ prime, this holds iff $−1$ is not fourth power mod $n$, aka a biquadratic residue.
If $a^4\equiv−1 \bmod p$, then $a$ has order $8$ mod $p$ and so $8$ divides $p-1$, by Lagrange's theorem of group theory.
Conversely, since the units mod $p$ form a cyclic group, there is an element $a$ of order $8$ when $8$ divides $p-1$. For this $a$, we have $a^4\equiv−1 \bmod p$.
Therefore,
$−1$ is fourth power mod $p$ iff $p \equiv 1 \bmod 8$
and so
$−1$ is not fourth power mod $p$ iff $p \equiv 2, 3, 5, 7 \bmod 8$
For $n$ not prime, quartic reciprocity will help.