N = int(input())
a = list(map(int, input().split()))
ans = 0
for i, v in enumerate(a):
   counter = len(a[i:])
   for j in range(counter):
      value = sum(a[i:i + j + 1])
      if value == 0:
         ans += 1
print(ans)