#include using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define FORR(x, arr) for(auto& x:arr) #define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; typedef pair P; ll MOD=1e9+7; const int NUM_=100005; static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1]; ll n; ll mod_pow(ll x, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } ll nck(ll N_, ll K_) { if (fact[0]==0) { inv[1]=fact[0]=factr[0]=1; for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD; } if(K_<0 || K_>N_) return 0; return factr[K_]*fact[N_]%MOD*factr[N_-K_]%MOD; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n; ll ret = 0; for (ll k = 1; k <= n; k++) { ll x = nck(n, k) * mod_pow(k, n-k) % MOD; ret = (ret + x) % MOD; } cout << ret << endl; return 0; }