N = int(input()) MOD = 10 ** 9 + 7 modinv = lambda a, mod=MOD: pow(a, -1, mod) comb = 1 ans = 0 for i in range(1, N + 1): comb = comb * (N - i + 1) * modinv(i) % MOD ans += comb * pow(i, N - i, MOD) ans %= MOD print(ans)