from itertools import accumulate

n = int(input())
A = list(map(int,input().split()))
acmA = [0] + list(accumulate(A))
ans = 0
for i in range(1,n+1):
  for j in range(n-i+1):
    if acmA[j+i]-acmA[j]==0: ans += 1
print(ans)