#include using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define fi first #define se second #define vec vector #define mat vector > typedef long long ll; typedef pair pll; typedef long double ld; const ll inf=1e9+7; const ll mod=998244353; ll rui(ll a,ll b){ ll res=1; ll x=a; while(b){ if(b&1)res=res*x%inf; x=x*x%inf; b/=2; } return res; } signed main(){ ll n;cin>>n; vectora(n+1); a[n]=1; bool f=0; rep(i,n){ cin>>a[i]; if(a[i]==0)f=1; } ll ans=1; vectorimos(n+2); vectorimo(n+2); ll j=0; ll now=1; rep(i,n){ if(j==n){ imos[i]+=j-i; imo[i+1]--; imo[j+1]++; }else{ while(j