#include #define LOCAL 0 #define lli long long int #define llu unsigned long long int #define ld long double #define all(v) v.begin(),v.end() #define pb push_back #define mp make_pair #define F first #define S second #define si(n) scanf("%d",&n) #define slli(n) scanf("%lld",&n); #define ss(n) scanf("%s",n); const long double EPS = 1e-10; const int MOD = 1000000007ll; const int mod1 = 1000000009ll; const int mod2 = 1100000009ll; int INF = (int)1e9; lli INFINF = (lli)1e18; int debug = 0; long double PI = acos(-1.0); using namespace std; int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;} int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;} int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;} int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;} int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;} int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);} int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;} templateostream&operator<<(ostream& os,const pair&p){os<<"["<ostream&operator<<(ostream& os,const vector&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<ostream&operator<<(ostream& os,set&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<ostream&operator<<(ostream& os,map&v){os<<"[";bool first=true;for(pair it:v){if(!first)os<<", ";first=false;os<<"("<void parr(T a[],int s,int e){cout<<"[";for(int i=s;i>N; for(int i=1;i<=N;i++) cin>>A[i]; for(int i=1;i<=N;i++){ valid[i][i] = true; for(int j=i+1;j<=N;j++){ if(A[j] < A[j-1]) break; valid[i][j] = true; } } dp[1][1] = 1; for(int j=2;j<=N;j++){ if(A[j] > A[j-1]) dp[1][j] = 1; else break; } for(int i=2;i<=N;i++){ for(int j=i;j<=N;j++){ if(!valid[i][j]) break; int sz1 = j - i + 1; for(int k = i-sz1;k>=1;k--){ int sz2 = i - k; if(!valid[k][i-1]) break; dp[i][j] = add(dp[i][j],mul(dp[k][i-1],mul(NCR::fact[sz2],NCR::invfact[sz2-sz1]))); } } } int ans = 0; for(int i=1;i<=N;i++) ans = add(ans,dp[i][N]); cout<