#include #include #include #include using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; ll dp[2][1050][2][2]; void add(ll &a, ll b){ a = (a + b % MOD) % MOD; } ll solve(int n){ if(n == 1)return 1; int curr = 0, next = 1; memset(dp[curr], 0, sizeof(dp[curr])); int segs = 3; dp[curr][0][0][0] = 2; for(int i=3;i<=n;i++){ memset(dp[next], 0, sizeof(dp[next])); for(int b=0;b<=segs-2;b++){ int s = segs - b; for(int p2=0;p2<=1;p2++)for(int p1=0;p1<=1;p1++){ if(b < p1 + p2)continue; ll now = dp[curr][b][p2][p1]; int nb = b; int ns = s; if(p2 == 0){ add(dp[next][b+1][p1][1], now * 2); ns -= 2; } else { add(dp[next][b+1][p1][1], now); add(dp[next][b][p1][1], now); ns -= 1; nb -= 1; } if(p1 == 1){ add(dp[next][b-1][0][0], now); nb -= 1; } if(nb > 0){ add(dp[next][b-1][p1][0], now * nb); } if(ns > 0){ add(dp[next][b][p1][0], now * ns); } } } swap(curr, next); ++segs; } return dp[curr][0][0][0]; } int main(){ int N; cin >> N; cout << solve(N) << endl; return 0; }