n=int(input())
a=list(map(int,input().split()))
b={}
s=0
ans=0
for i in range(n):
  s+=a[i]
  if s not in b:
    if s==0:
      b[s]=1
      ans+=1
    else:
      b[s]=0
  else:
    b[s]+=1
    ans+=b[s]
print(ans)