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