P = int(input()) ans = 1 now = 1 for i in range(P-1,0,-1): now *= i now %= P ans += now ans %= P print(ans * pow(now,-1,P) % P)