TITLE: Why is the sum modulo n of elements in $\mathbb{Z}_n^*$ equal to 0?
QUESTION [6 upvotes]: I'm talking about the set
$$\mathbb{Z}_n^* = \{x \in \mathbb{Z}_n : \text{gcd}(x,n)=1\}$$
I noticed that for $n>2$, if you add all the elements in the set, you get $0\mod{n}$. Can someone explain why this is? I also noticed that if $a$ is in the set, then so is $n-a$, but how can I go about showing that $\text{gcd}(n-a,n)=1$?
For example, $$\mathbb{Z}_8^* = \{1,3,5,7\}$$
And $1+7 = 8$, $3+5=8$. So $1+3+5+7 \equiv_8 0$

REPLY [3 votes]: Hint $ $ Negation $\rm\:n\to -n\:$ is an involution $\rm\:-(-n) \equiv n,$ so the cycles (orbits) of this permutation have length $2$ or $1.\ $ But length $1$ is not possible since $\rm\: -a \equiv a\:$ $\Rightarrow$ $\rm\:n\:|\:2a\:$ $\Rightarrow$ $\rm\:n\:|\:2,\:$ by $\rm\:(n,a)=1.\ $  Thus all cycles have length $\,2\,$ so have form $\rm\:(\color{#c00}{a,\,-a}).\:$ These cycles partition $\Bbb Z_n^*$  into pairs, and each pair sums to $\,\rm \,0 \equiv \color{#c00}{a -a},\,$  hence the entire sum is also $\,\equiv 0$.
This is a prototypical example of Wilson's theorem for groups.