N = gets.to_i
A = gets.split(" ").map { |e| e.to_i }

cur = 0
sum = []
for i in 0..N-1 do
  cur += A[i]
  sum << cur
end

count = 0
for k in 0..N-1 do
  if sum[k] == 0 #0番目からk番目までが0
    count += 1
  end
  for i in k+1..N-1 do
    if sum[i]-sum[k] == 0 #k+1番目からi番目までの和が0
      count += 1
    end
  end
end

puts count