#include #define maxn 2000 #define mod 1000000007 using namespace std; int arr[maxn]; unsigned long long stor[maxn],istor[maxn]; unsigned long long dp[maxn][maxn]; unsigned long long power(int n,unsigned long long k ,int m=1000000007) //return n^k % m { if(k==0) return 1; if(k==1) return n; unsigned long long f=power(n,k/2,m); unsigned long long p=(f*f)%m; if(k%2!=0) p=(p*n)%m; return p; } int main() { stor[0]=1; istor[0]=power(stor[0],mod-2,mod); for(int i=1;i>n; for(int i=1;i<=n;i++) cin>>arr[i]; dp[n+1][0]=1; for(int i=n;i>0;i--) { dp[i][0]=0; for(int l=1;l<=n-i+1;l++) { dp[i][l]=0; int flag=0; for(int j=0;jarr[i+j+1]) { flag=1; break; } } if(flag) continue; for(int j=0;j<=l;j++) { dp[i][l]+=(((dp[i+l][j]*stor[l])%mod)*istor[l-j])%mod; dp[i][l]%=mod; } } for(int l=n-i+2;l<=n;l++) dp[i][l]=0; } unsigned long long ans=0; for(int i=1;i<=n;i++) { ans+=dp[1][i]; ans%=mod; } cout<