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()    
c=set(b)
ans=b.count(0)
for i in c:
    j=b.count(i)
    ans+=j*(j-1)//2
print(ans)