#include using namespace std; using ll=long long; #include using namespace atcoder; using mints=modint998244353; #pragma GCC target ("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i,a,b) for(it i=(it)(a);i<=(it)b;i++) #define nrep(i,a,b) for(it i=(it)(a);i>=(it)b;i--) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define moda 998244353LL #define modb 1000000007LL #define gyaku 166374059LL #define dai 2500000000000000000LL #define sho -dai #define aoi 1e+18 #define tyu 2500000000 #define giri 1000000000 #define en 3.14159265358979 #define eps 1e-14 #define endl '\n' #define yn(x) cout<<(x?"Yes\n":"No\n"); #define YN(x) cout<<(x?"YES\n":"NO\n"); #define ci(x) cin>>x; #define fi(x) cout<; using ip=pair; using mint=modint; using minto=modint1000000007; using vi=vector; using ivi=vector; using vd=vector; using vs=vector; using vc=vector; using vb=vector; using vp=vector

; using ivp=vector; using vm=vector; using vms=vector; using vmo=vector; using sp=set

; using isp=set; using ss=set; //using sc=set; using si=set; using isi=set; using svi=set; using vvi=vector; using ivvi=vector; using vvd=vector; using vvs=vector; using vvb=vector; using vvc=vector; using vvp=vector; using ivvp=vector; using vvm=vector; using vvms=vector; using vvmo=vector; using vsi=vector; using ivsi=vector; using vsp=vector; using ivsp=vector; using vvsi=vector; using ivvsi=vector; using vvsp=vector; using ivvsp=vector; using vvvi=vector; using ivvvi=vector; using vvvd=vector; using vvvb=vector; using vvvm=vector; using vvvms=vector; using vvvmo=vector; using vvvvi=vector; using ivvvvi=vector; const it dx[4]={0,1,0,-1}; const it dy[4]={1,0,-1,0}; template void scan(vector &a){ rep(i,0,a.size()-1)cin>>a[i]; } template void scan(vector &a,vector&b){ rep(i,0,a.size()-1)cin>>a[i]>>b[i]; } template void scan(vector> &a){ rep(i,0,a.size()-1)cin>>a[i].first>>a[i].second; } template void dec(vector &a){ rep(i,0,a.size()-1)a[i]--; } it gcda(it a,it b){ if(!a||!b){ return max(a,b); } while(a%b&&b%a){ if(a>b)a%=b; else b%=a; } return min(a,b); } it lcma(it a,it b){ return a/gcda(a,b)*b; } bo su(ch c){return ('0'<=c&&c<='9');} const int MOD = modb; vi fact, fact_inv, inv; /* init_nCk :二項係数のための前処理 計算量:O(n) */ void init_nCk(int SIZE){ fact.resize(SIZE+5); fact_inv.resize(SIZE+5); inv.resize(SIZE+5); fact[0]=fact[1]=1; fact_inv[0]=fact_inv[1]=1; inv[1]=1; rep(i,2,SIZE+4){ fact[i]=fact[i-1]*i%MOD; inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; fact_inv[i]=fact_inv[i-1]*inv[i]%MOD; } } /* nCk :MODでの二項係数を求める(前処理 int_nCk が必要) 計算量:O(1) */ int nCk(int n, int k){ assert(!(nrv)swap(ru,rv); siz[ru]+=siz[rv]; par[rv]=ru; } bool same(int u,int v){ return leader(u)==leader(v); } int size(int u){ return siz[leader(u)]; } }; struct dsu2{ ivvi par,siz;int h,w; void init(int x,int y){ h=x,w=y;par.resize(h),siz.resize(h); rep(i,0,h-1) rep(j,0,w-1)par[i].emplace_back(i*w+j); rep(i,0,h-1) rep(j,0,w-1)siz[i].emplace_back(1); } int leader(int x,int y){ if(par[x][y]==x*par[0].size()+y)return x*w+y; return par[x][y]=leader(par[x][y]/w,par[x][y]%w); } void merge(int a,int b,int c,int d){ int ru=leader(a,b),rv=leader(c,d); if(ru==rv)return; if(size(ru/w,ru%w)>n; ivi a(n);scan(a); ivi zero;zero.emplace_back(-1); rep(i,0,n-1) if(!a[i])zero.emplace_back(i); zero.emplace_back(n); it ans=0; rep(i,0,zero.size()-2){ it e=zero[i+1]-zero[i]; ans+=e*(e-1)/2; } cout<