What is a formal proof for why there are exactly $\frac{p-1}{2}$ elements that are not quadratic residues? 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?

Your argument, as well as I can follow it, would seem to extend to a proof that $\mathbb{Z}_N^*$ has $\phi(N)/2$ non-residues for any $N$, not just when $N$ is prime.  But that's not true in general:  If $N=15$, for example, there are $2$ quadratic residues and $6$ non-residues, not $4$ of each.  So what seems to be missing is some essential use of the fact that you're working with primes (beyond the fact that $\phi(p)=p-1$).
