n = int(input())
a = [int(i) for i in input().split()]
sum = [0 for i in range(n)]
counter = 0

for i in range(n):
  sum = [sum[i] + a[i] for i in range(len(sum))]
  counter += sum.count(0)
  a.pop(0)
  sum.pop()

print(counter)