N = gets.to_i
a = gets.split(" ").map(&:to_i)
s = [0]
0.upto(a.size-1) do |i|
  s.push(s[i] + a[i])
end
cnt = 0
0.upto(s.size-2) do |i|
  (i+1).upto(s.size-1) do |j|
    cnt += 1 if s[i] == s[j]
  end
end
puts cnt