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