// yukicoder: No.573 a^2[i] = a[i] // 2019.7.6 bal4u #include typedef long long ll; #define M 1000000007 #define MAX 100000 ll fact[MAX+2], inv[MAX+2], factinv[MAX+2]; ll comb(int n, int k) { return fact[n] * factinv[k] % M * factinv[n-k] % M; } ll bigPow(int a, int p) { ll r = 1; while (p) { if (p & 1) r = r * a % M; a = (ll)a * a % M; p >>= 1; } return r; } int main() { int i, N, ans; scanf("%d", &N); fact[0] = 1, inv[1] = 1, factinv[0] = 1; for (i = 1; i <= N; i++) fact[i] = fact[i-1] * i % M; for (i = 2; i <= N; i++) inv[i] = (M + (-(M/i) * inv[M % i]) % M) % M; for (i = 1; i <= N; i++) factinv[i] = factinv[i-1] * inv[i] % M; ans = 0; for (i = 0; i <= N; i++) ans = (ans + comb(N, i) * bigPow(N-i, i)) % M; printf("%d\n", ans); }