from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = list(accumulate(li))
point = 0
for i,j in enumerate(lin,1):
    if j == 0:
        point += i
print(point)