If $p$ is prime, I was trying to understand why $Z^\*\_N$ has $\frac{p-1}{2}$ non-quadratic elements **exactly**.

The current proof that I have is sort of more of an intuitive argument (or at least it doesn't feel rigorous enough to me) but I wanted to make it more formal.

Currently this is what I have:

The square root function maps 1 element to 2 elements. i.e. given $a = x^2 \in Z^\*\_N $ it maps it to either $x$ or $-x$. Therefore, if each element has 2 square roots, eventually, we only need have the number of elements to have an element in the co-domain assigned (since the mapping is 1 to 2 to a finite set and both the domain and co-domaine are finite and the same size $p-1$). Since the mapping covers all its target set, then we can argue its a surjection (i.e. all elements of the co-domain are mapped) and (p-1)/2 elements are covered.

This argument feels correct, except I am not sure if there might be some subtle number theoretic thing or math detail that I am missing. Is there such a thing missing?