#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVL; typedef vector VVI; typedef pair P; typedef pair PL; const ll mod = 1000000007; const int N = 200010; ll fact[N], invf[N]; ll add(ll x, ll y){ return (x+y)%mod; } ll mul(ll x, ll y){ return (x%mod)*(y%mod)%mod; } ll powll(ll x, ll y){ ll res = 1LL; while(y){ if (y & 1LL) res *= x; res %= mod; x = (x*x) % mod; y >>= 1LL; } return res; } ll divll(ll x, ll y){ return (x * powll(y,mod-2)) % mod; } ll nPr(ll n, ll r){ if (n < r || r < 0) return 0; return mul(fact[n], invf[n-r]); } ll nCr(ll n, ll r){ if (n < r || r < 0) return 0; return mul(mul(fact[n], invf[r]), invf[n-r]); } int main() { fact[0] = invf[0] = 1; FOR(i,1,N-1){ fact[i] = (fact[i-1] * i) % mod; invf[i] = divll(invf[i-1], i); } ll n; cin >> n; ll ans = 0; FOR(i,1,n){ ll tmp = nCr(n, i); tmp = (tmp * powll(i,n-i)) % mod; ans = (ans + tmp) % mod; } cout << ans << endl; return 0; }