import itertools
N = int(input())
a = list(map(int, input().split()))
count = 0
b = list(itertools.combinations(range(N+1), 2))
l = len(b)
for i in range(l):
  c = b[i]
  d = c[0]
  e = c[1]
  if sum(a[d : e]) == 0:
    count += 1
print(count)