Square free and congruence modulo n 
I am trying to show that if $a^n\equiv a\pmod n$ for all integers $a$ then $n$ is square free. 

I have an idea to start with the contradiction that suppose $n=p^2m$ for some prime $p$, then n does not divide $a^{p^2m}-a$ for some integer $a$. Any hints would be appreciated thanks.

Suppose that $n$ is divisible by $p^2$. Let $a=p$. Since $p^n$ is divisible by $p^2$, the number $p^2$ does not divide $p^n-p$.
