Alternative proof of : $n = \sum_{d|n} \phi(d)$ which is the sum of Euler Phi Function over Divisors
The idea is you want to count the elements in $\mathbb{Z}_{n}$ in two ways. First, we note that $|\mathbb{Z}_{n}| = n$. We now count in a second way. Recall that for every $1\leq d|n$, there exists a unique subgroup of order $d$ in $\mathbb{Z}_{n}$, which is precisely $\mathbb{Z}_{d}$. Furthermore, these are the only subgroups of $\mathbb{Z}_{n}$. Now count the generators of $\mathbb{Z}_{d}$; there are $\phi(d)$ such generators. By Lagrange's Theorem, we have that $\langle a \rangle$ is a subgroup of $\mathbb{Z}_{n}$ for every $a \in \mathbb{Z}_{n}$. So in fact:
$$\sum_{1 \leq d|n} \phi(d) = n$$
Sorry I'm just going to suggest a different method of proof.
Every element of $Z_n$ generates exactly one cyclic subgroup of some order $d\mid n$ for some $d$. Additionally $Z_n$ has a unique subgroup of order $d$ for each $d\mid n$. Then let $D_n$ be the set of divisors of $n$. Now we can say that if $\alpha(a,d) : Z_n \times D_n$ is the indicator function that is 1 when $a$ generates a subgroup of order $d$ and 0 otherwise, then $$ n=\sum_{a\in Z_n}1 = \sum_{a\in Z_n}\sum_{d\in D_n}\alpha(a,d) = \sum_{d\in D_n}\sum_{a\in Z_n} \alpha(a,d) = \sum_{d\mid n} \phi(d).$$