nag = int(input())
kaz = list(map(int,input().split(" ")))
cou = 0
for i in range(nag):
    kar = 0
    for j in range(nag - i):
       kar += kaz[i + j]
       if kar == 0:
           cou += 1

print(cou)