P = int(input()) x = 1 t = 1 for i in reversed(range(1, P)): t *= i t %= P x += t x %= P print(x * pow(t, -1, P) % P)