#include using namespace std; typedef long long ll; const ll mod = 1e9+7; ll fac[200000+1],ifac[200000+1]; ll mpow(ll x,ll n){ ll res = 1; while(n != 0){ if(n&1) res = res*x % mod; x = x*x % mod; n = n >> 1; } return res; } ll comb(ll a,ll b){ if(a==0 && b==0) return 1; if(a struct Stirling{ vector > S; constexpr Stirling(int MAX) noexcept : S(MAX+1, vector(MAX+1, 0)) { S[0][0] = 1; for (int n = 1; n <= MAX; ++n) { for (int k = 1; k <= n; ++k) { S[n][k] = (S[n-1][k-1] + S[n-1][k] * k)%mod; } } } constexpr T stir(int n, int k) { if (n < 0 || k < 0 || n < k) return 0; return S[n][k]; } }; int main(){ int n; ll ans=0; cin >> n; Stirling s(555); calc_fac(); for(int i = 1;i <= n;i ++){ for(int x = 1;x <= n;x ++){ ans = (ans + comb(n,x)*s.stir(x,i)%mod*mpow(i*(i-1),n-x)%mod)%mod; } } cout << ans << endl; return 0; }