n = gets.to_i
array = gets.chomp.split(' ').map(&:to_i)
stack_array = [0]
array.each.with_index do |v, i|
  stack_array << stack_array[-1] + v
end

count = 0
(0..n).each do |i|
  (1..(n-i)).each do |j|
    count += 1 if stack_array[i+j] == stack_array[i]
  end
end
puts count
