#include #include #include #include using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; ll dp[556][556]; ll comb[556][556]; ll power[556][556]; int main(void) { int i, j, n; cin >> n; dp[0][0] = 1; REP (i,1,n) REP (j,1,i) if (j > 0) dp[i][j] = (dp[i-1][j-1] + j * dp[i-1][j]) % MOD; comb[0][0] = 1; REP (i,1,n) rep (j,i+1) comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD; REP (i,1,n) { power[i][0] = 1; REP (j,1,n) power[i][j] = power[i][j-1] * i * (i-1) % MOD; } int ans = 0; REP (i,1,n) REP (j,1,i) ans = (ans + comb[n][i] * dp[i][j] % MOD * power[j][n-i]) % MOD; cout << ans << endl; return 0; }