I have a question on my homework that says to prove $a^{p(p-1)}\equiv 1 \pmod{p^2}$ and hints at using the proof for fermats little theorem as something to get us started. A TA also hinted at using Euler's totient function -- which we haven't proved or done much with.

Mirroring the FLT proof, here's what I was thinking so far:

Define the set $S_{1}= [{1,2,3,4,\ldots,p^2-1}]$. Define another set $S_{2}= [{1a,2a,3a,4a,\ldots,(p^2-1)a}]$

Since they hinted to mimic FLT proof, Im thinking that I prove that the sets are equal. I can do that by saying $S_{1}$ is a subset of $S_{2}$ and $S_{2}$ is a subset of $S_{1}$.

But I don't know how to proceed from there. I also have no idea about the totient function and how that's relevant.

I think once I find out how to say $S_{1} = S_{2}$ I can say, like how we do for FLT, that their products are equal.

Then somehow leading it back to $(p^2-1)! = a^{p^2-1}(p^2-1)$, and saying that since p is prime, $p^2-1$ must have an inverse $\bmod p$ and using that to say that yes indeed $a^{p(p-1)}\equiv1\pmod{p^2}$

I guess I'm just stuck on the middle step -- proving the sets are equal

EDIT: Forgot to mention that we're given $\gcd(a,p) = 1$