#include #define pb push_back #define sqr(x) (x)*(x) #define sz(a) int(a.size()) #define reset(a,b) memset(a,b,sizeof(a)) #define oo 1000000007 using namespace std; typedef pair pii; typedef long long ll; const int maxn=1222; ll dp[maxn][maxn],C[maxn][maxn],fac[maxn]; int n,a[maxn]; int main(){ // freopen("input.txt","r",stdin); cin>>n; for(int i=1; i<=n; ++i) cin>>a[i]; C[0][0]=1; fac[0]=1; for(int i=1; i<=n; ++i){ C[i][0]=1; fac[i]=fac[i-1]*i%oo; for(int j=1; j<=i; ++j) C[i][j]=(C[i-1][j]+C[i-1][j-1])%oo; } for(int i=1; i<=n; ++i){ if(i>1 && a[i]i+1 && a[j]