/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. * Created By : Aditya Agarwal * IT, MNNIT-ALLAHABAD * aditya.mnnit15@gmail.com _._._._._._._._._._._._._._._._._._._._._.*/ #include using namespace std; #define MP make_pair #define pb push_back #define rep(i,n) for(int i=0;i=a;i--) #define X first #define Y second //i/o #define inp(n) scanf("%d",&n) #define inpl(n) scanf("%lld",&n) #define inp2(n,m) inp(n), inp(m) #define inp2l(n,m) inpl(n), inpl(m) //cost #define MOD 1000000007 #define MOD_INV 1000000006 #define MAX 100009 #define INF 999999999 #define mp make_pair typedef long long ll; typedef pair< pair,ll > pairs; int n; int a[1205],is[1205],cum[1205]; ll dp[1205][1205],fact[1205],ifact[1205]; ll powd(ll base,int ex){ ll res=1; while(ex){ if(ex%2==1) res=(res*base)%MOD; ex/=2; base=(base*base)%MOD; } return res; } ll comp(int n,int r){ ll ans=fact[n]; ans=(ans*ifact[n-r])%MOD; //cout<=0;i--){ ifact[i]=((i+1)*ifact[i+1])%MOD; } REP(i,1,n){ inp(a[i]); } REP(i,2,n){ if(a[i]