N=int(input())
A=[int(a) for a in input().split()]
S=[0]
for i in range(N):
  S.append(S[-1]+A[i])
S.sort()
last=0
n=1
ans=0
for i in range(1,N+1):
  if S[i]==last:
    n+=1
  else:
    last=S[i]
    ans+=n*(n-1)//2
    n=1
  
ans+=n*(n-1)//2
print(ans)
