#include #include using namespace std; typedef long long ll; typedef long double ld; #define PB push_back #define MP make_pair #define MOD 1000000007LL #define endl "\n" const ll UNDEF = -1; const ll INF=1e9; template inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; } template inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; } typedef pair pll; template T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; } template T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; } ll mod_pow(ll a, ll n) { ll ret = 1; ll p = a % MOD; while (n) { if (n & 1) ret = ret * p % MOD; p = p * p % MOD; n >>= 1; } return ret; } const ll mn=1200+2; inline ll mul(ll x,ll y) {return (x*y)%MOD;} inline ll add(ll x,ll y) {return (x+y+MOD+MOD)%MOD;} const ll MAXFACT=mn+4; ll fact[MAXFACT+1],invfact[MAXFACT+1]; void init() { ll got=1; for (ll x=0;x<=MAXFACT;x++) { fact[x]=got; got=mul(got,x+1); } got=mod_pow(got,MOD-2); for (ll x=MAXFACT;x>=0;x--) { got=mul(got,x+1); invfact[x]=got; } } ll spec_binom(ll n,ll k) { // Binomial * k! if (n0 && a[x-1]>a[x]) break; f[x+1][x+1]=1; } } for (ll x=0;xa[y]) break; maxy=y; } for (ll t=1;t<=n;t++) { ll val=f[x][t]; if (val==0) continue; val%=MOD; ll limy=min(maxy,x+t-1); for (ll y=x;y<=limy;y++) { ll newt=y-x+1; ll choose=spec_binom(t,newt); f[y+1][newt]=(val*choose + f[y+1][newt])%MOD; } } } /*for (ll x=0;x<=n;x++) { for (ll t=1;t<=n;t++) { printf("x:%lld t:%lld f:%lld\n",x,t,f[x][t]); } }*/ ll final=0; for (ll t=0;t<=n;t++) { final+=f[n][t]; } final%=MOD; printf("%lld\n",final); }