#include #define MOD 1000000007LL using namespace std; typedef long long ll; int n,a[1205]; ll dp[1205][1205],fact[1205],invfact[1205]; ll modpow(ll b, int e){ if(e==1) return b; ll half=modpow(b,e>>1); half=half*half%MOD; if(e&1) half=half*b%MOD; return half; } ll f(int pos, int len){ if(pos==n) return 1ll; if(dp[pos][len]>=0ll) return dp[pos][len]; dp[pos][len]=ll(len); for(int x=2;x<=len;x++){ if(pos+x>n||a[pos+x-1]