#include using namespace std; typedef long long int ll; typedef pair pii; typedef vector vi; typedef vector > vii; #define rrep(i, m, n) for(int (i)=(m); (i)<(n); (i)++) #define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++) #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--) #define rev(i, n) for(int (i)=(n)-1; (i)>=0; (i)--) #define vrep(i, c) for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++) #define ALL(v) (v).begin(), (v).end() #define mp make_pair #define pb push_back template inline void minup(T1& m, T2 x){ if(m>x) m=static_cast(x); } template inline void maxup(T1& m, T2 x){ if(m(x); } #define INF 1000000000 #define MOD 1000000007LL #define EPS 1E-12 const int MAX_N = 555; int N; ll C[MAX_N+1][MAX_N+1]; ll S[MAX_N+1][MAX_N+1]; ll P[MAX_N+1][MAX_N+1]; ll res; int main() { cin >> N; rep(i, N+1) C[i][0] = 1LL; rep(i, N) rep(j, i+1) C[i+1][j+1] = (C[i][j] + C[i][j+1]) % MOD; S[0][0] = 1LL; rep(i, N) rep(j, i+1) S[i+1][j+1] = (S[i][j] + ((j + 1) * S[i][j+1]) % MOD) % MOD; rep(i, N+1) P[i][0] = 1LL; rep(i, N+1) rep(j, N+1) P[i][j+1] = P[i][j] * i * (i-1) % MOD; erep(i, 1, N) erep(j, 1, i) res = (res + ((C[N][i] * S[i][j]) % MOD * P[j][N-i]) % MOD) % MOD; cout << res << endl; return 0; }