def inv(x): return pow(x, MOD-2, MOD) def C(n, r): return fact[n]*inv(fact[r])*inv(fact[n-r]) N = int(input()) MOD = 10**9+7 fact = [1] for i in range(1, N+1): fact.append(fact[-1]*i%MOD) ans = 0 for i in range(N+1): ans += pow(i, N-i, MOD)*C(N, i) ans %= MOD print(ans)