import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)