#include #include #include using namespace std; typedef long long int ll; const ll MOD = 1e9 + 7, N = 100000; ll n, ans = 0, lc = 1, cmb[2][N+1] = {}; ll pw2(ll a, ll b) { ll la = a,val=1; for (; b != 0;b= b >> 1) { if ((b & 1) != 0) val = (val*la) % MOD; la = (la*la) % MOD; } return val; } void comb() { cmb[0][0] = 1; for (int i = 1; i <= n; i++) { cmb[i % 2][0] = 1; cmb[i % 2][i] = 1; for (int j = 1; j < i; j++) { cmb[i % 2][j] = cmb[(i - 1) % 2][j - 1] + cmb[(i - 1) % 2][j]; cmb[i % 2][j] %= MOD; } fill(cmb[(i-1) % 2], cmb[(i-1) % 2 + 1],0); } } int main() { cin >> n; comb(); for (int i = 1; i <= n; i++) { ans += (cmb[n%2][i]%MOD) * pw2(i, n - i); ans %= MOD; } cout << ans << endl; return 0; }