def fact(n)
  if n>1 then return n*fact(n-1)
  else return 1 end
end
def combi(n,r)
  return fact(n)/fact(r)/fact(n-r)
end
n=gets.to_i
a=gets.split.map(&:to_i)
s=[0]
n.times{|i|
  s<<s[i]+a[i]
}
s=s.sort
t=0
c=1
sum=0
n.times{|i|
  if t==s[i+1] then c+=1 
  else
    sum+=combi(c,2)
    c=1
  end
  t=s[i+1]
}
if c>1 then sum+=combi(c,2) end
p sum