#include #include #include #include #include using namespace std; const long long modul = 1000000007; long long fakt[1300],bin[1500][1500],dp[1500][1500]; long long a[2000],n; int main() { scanf("%lld",&n); for (long long i=n;i>=1;i--)scanf("%lld",&a[i]); fakt[0]=1; for (long long i=1;i<=1200;i++){fakt[i]=fakt[i-1]*1LL*i;fakt[i]%=modul;} bin[0][0]=1; for (long long i=1;i<=n;i++) for (long long j=0;j<=n;j++) { if (j==0){bin[i][j]=1;continue;} bin[i][j]=bin[i-1][j]+bin[i-1][j-1]; bin[i][j]%=modul; } dp[1][1]=1; //for (int i=0;i<=1200;i++)dp[0][i]=1; for (long long i=2;i<=n;i++) { long long pok = i; for (long long j=i-1;j>=1;j--)if (a[j]