n=int(input())
l=list(map(int,input().split()))
c=0
l1=[]
for i in l:
  c+=i
  l1.append(c)
l2={}
for i in l1:
  if i in l2:
    l2[i]+=1
  else:
    l2[i]=1
s=0
for i in l2:
  s+=l2[i]*(l2[i]-1)/2
print(s)