/*********** [ scopeInfinity ] ******************/ #include using namespace std; typedef long long ll; typedef long double ld; typedef std::vector vll; typedef std::vector vi; #define endl '\n' #define mp make_pair #define pb(x) push_back((x)) #define what_is(x) cerr << #x << " is " << x << endl; ll MOD = 1e9+7; ll INF = LLONG_MAX; vector &split(const std::string &s, char delim, vector &e) { stringstream ss(s); string item; while(getline(ss, item, delim)) e.push_back(item); return e; } ll Pow(ll a ,ll b ,ll Mo){ ll ans = 1; for (; b; b >>= 1, a = a * a % Mo) if (b&1) ans = ans * a % Mo; return ans; } vector Zfunc(string &s) { int n=s.length(); vector z(n,0); for(int i=1,l=0,r=0;i cI; std::vector FAC,FACI; std::vector > DP; int getVal(int num,int mx,int first,int index) { if(num==0) return 1; int &ans = DP[index][mx]; if(ans!=-1) return ans; ans=0; int M=min(min(num,mx),cI[index]); for (int i = 1; i <= M; ++i) { ll sol = getVal(num-i,i,0,index+i); if(!first) sol=(sol*FAC[mx])%MOD*FACI[mx-i]%MOD; ans = (ans+sol)%MOD; // cout<>N; FAC=std::vector (N+1,1); FACI=std::vector (N+1,1); for (int i = 1; i <= N; ++i) { FAC[i]=(FAC[i-1]*i)%MOD; } for (int i = 0; i <= N; ++i) { FACI[i]=Pow(FAC[i],MOD-2,MOD); } DP=std::vector >(N+1,std::vector(N+1,-1)); std::vector num(N); for (int i = 0; i < N; ++i) { cin>>num[i]; } cI= std::vector (N,1); for (int i = N-2; i >= 0; --i) { if(num[i+1]>num[i]) cI[i]=1+cI[i+1]; } cout<