ll b,c;{ll@n,@a[n];rep(i,n){if(a[i])b+=c;else b+=(c=i+1);}wt(b);}