N = int(input())
ls = list(map(int, input().split()))

num = 0
for i in range(N):
  if sum(ls[i:]) == 0:
   	num += 1
  for j in range(N - i -1):
    if sum(ls[i:-j-1]) == 0 and ls[i:-j-1] != []:
      num += 1
print(num)
  