フェルマーの小定理
and the second equality uses Fermat's little theorem, which is