#include using namespace std; #define M 1000000007 #define pe(a,b) {a+=b;a%=M;} #define te(a,b) {a*=b;a%=M;} typedef int tint; #define int unsigned long long //memo[ind][#]. or just generate all. int n; int *m; int *mem; int *fgm; int fg(int i,int j) { return fgm[i*n+j]=fgm[i*n+j-1]*(i-j+1)%M; /* int r=1; while(j-- && !fgm)te(r,i--); return r; */ } int get(int i,int j) { if(i+j>n)return 0; if(mem[i*n+j])return mem[i*n+j]-1; int p=0; for(int i2=i;i2> n; int m[n]; ::m=m; int mem[n*n]={}; ::mem=mem; int fgm[(n+1)*(n+1)]={}; ::fgm=fgm; for(int i=0;i<=n;i++)fgm[i*n]=1; int pi=0; bool f=true; int prev=0; for(int m_i = 0; m_i < n; m_i++){ cin >> m[m_i]; if(m[m_i]