func main() var n: int :: cui@inputInt() var a: []int :: #[n]int for i(0, n - 1) do a[i] :: cui@inputInt() end for var posLast0: int :: -1 var cntNon0: int :: 0 for i(0, n - 1) if(a[i] = 0) do posLast0 :: i end if do cntNon0 :+ i - posLast0 end for var ans: int :: n + n * (n - 1) / 2 - cntNon0 do cui@print("\{ans}\n") end func