#include using namespace std; const double pi=acos(-1.0); const double eps=1e-9; #define fi first #define se second #define mp make_pair #define pb push_back #define re return #define vi vector #define pii pair #define pll pair #define task #define file freopen("task.in","r",stdin);freopen("task.out","w",stdout) #define inp freopen("input.txt","r",stdin) #define outp freopen("output.txt","w",stdout) typedef long long ll; const int N = (int)2e3; const ll M = (ll)1e9+7; ll n,a[N],ans[N][N],ANS,c[N][N],fact[N]; bool block[N]; ll Pow(ll x, ll a) { if(a==0) return 1; ll t = Pow(x,a/2); if(a%2 == 0) return t*t%M; return x*t%M*t%M; } int main() { ios:: sync_with_stdio(false); //inp;outp; //file; fact[0] = 1; for(int i=1;i> n; for(int i=0;i> a[i]; for(int i=0;i a[i+1]) block[i] = true; for(int i=0;i=0;j--) { if(block[j] && j!=i)break; int l = i - j + 1; if(j==0) { ans[i][l] = 1; continue; } for(int k = l; k<=n;k++) { ans[i][l] += ans[j-1][k]*c[k][l]; if(ans[i][l] >= M)ans[i][l] %= M; } } /*for(int i=0;i