import collections
n,*a=map(int,open(0).read().split())
b=[0]*n
b[0]=a[0]
for i in range(1,n):
    b[i]=b[i-1]+a[i]
b.sort()    
b=[0]+b
ans=0
l=collections.Counter(b)
for i in l.values():
    ans+=i*(i-1)//2
print(ans)