#include #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) #define MOD 1000000007LL using namespace std; typedef long long ll; ll N; ll fact[100001], ifact[100001]; ll modulo_power(ll a, ll n) { if(n == 0) return 1; if(n % 2 == 0) return modulo_power((a * a) % MOD, n / 2); return (a * modulo_power(a, n - 1)) % MOD; } ll combination(ll n, ll r) { return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD; } int main(void) { cin >> N; fact[0] = 1; REP(i, 1, 100001) fact[i] = fact[i - 1] * i % MOD; REP(i, 0, 100001) ifact[i] = modulo_power(fact[i], MOD - 2); ll ans = 0; REP(i, 1, N + 1) ans = (ans + combination(N, i) * modulo_power(i, N - i) % MOD) % MOD; cout << ans << endl; }