Yes. Two other points:

- Probably turn `\pmod n` into `\pmod p`
- Instead of just removing \phi n, work it out step by step, starting from the inverse (since that's what you want)

Combined:

```
a^{-1} \equiv a^{\phi(p) - 1} \equiv a^{p - 2} \pmod p
```