const ll mod = 1e9 + 7; constint N = 1e6 + 10; ll fac[N]; ll inv[N];
ll quick_pow(ll a, ll b) { ll ans = 1; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; }
voidinit() { fac[0] = 1; for(int i = 1;i < N; i++) fac[i] = fac[i - 1] * i % mod; inv[N - 1] = quick_pow(fac[N - 1], mod - 2); for(int i = N - 2;i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } }
ll C(int m, int n) { ll ans = fac[m] * inv[n] % mod * inv[m - n] % mod; return ans; }
intmain() { init(); int n; cin >> n; int pre = 1000; int cnt = 0; ll ans = 1; for(int i = 1;i <= n; i++) { int x; cin >> x; if(!x) cnt++; else { int len = pre - x + 1; ans = ans * C(cnt + len - 1, len - 1) % mod; pre = x; cnt = 0; } } if(cnt) { ans = ans * C(cnt + pre - 1, pre - 1) % mod; } cout << ans << endl; }