n=int(input())
A=list(map(int,input().split()))
s=[0]
for i in range(n):
    s.append(s[-1]+A[i])
cnt=[]
S=set(s)
for i in S:
    cnt.append(s.count(i))
ans=0
for i in cnt:
    if 1<i:
        ans+=i*(i-1)//2
print(ans)
