from itertools import accumulate

n=int(input())
*a,=map(int,input().split())
 
b=[0]+a
b=list(accumulate(b))

L={}
for i in range(n+1):
      if b[i] in b:
            if b[i] in L:
                  L[b[i]]+=1
            else:
                  L[b[i]]=1
ans=0
for i in L.values():
      if i>1:
            ans+=i*(i-1)//2
print(ans)     
