N=int(input())
A=list(map(int,input().split()))
B=[0]
for i in range(N):
  B+=[B[i]+A[i]]
C=[]
ans=0      
B.sort()
c=1
for i in range(1,N+1):
  if B[i]==B[i-1]:
    c+=1
  else:
    ans+=c*(c-1)//2
    c=1
ans+=c*(c-1)//2
print(ans)