n = int(input())
a = map(int,input().split())
a = list(a)
count = 0
for i in range(len(a)):
  start = 0
  for j in range(len(a)-i):
    if sum(a[start:start+i+1]) == 0:
      count += 1
    start += 1
print(count)