For an abelian group $G$ I have shown that $$ G=Z(p^{l_1})\times...\times Z(p^{l_r})\Rightarrow G^p\cong Z(p^{l_1-1})\times...\times Z(p^{l_r-1}) \, \text{and ord} (G/G^p)=p^r. $$
A $p$-group $G$ is defined by the fact that for $p$ prime, for all $a\in G$ there exists exponents $n(a)\in \mathbb{N}$ with $\text{ord}(a)=p^{n(a)}$.
Why does it follow from the above that the number $r$ of cyclical factors is an invariant of the $p$-group $G$?
//edit: Why does it follow that the number of non-trivial factors in $G^{p^l}$ is invariant?
The order of $G/G^p$ is independent of any way of expressing $G$ as a product of subgroups and so $p^r$ and hence $r$ is an invariant.