def check(idx,arr)
  count = 0
  checked = []
  idx.each do |id|
    chk = []
    id.each do |i|
      chk << arr[i]
    end
    checked << chk
  end
  return checked.count{|chk| chk.inject(:+) == 0}
end


n = gets.to_i
arr = gets.chomp.split(" ").map(&:to_i)

count = 0

# 01 12 23 34 45 56
checked_idx = Array.new(n-1){|i| [i,i+1]}

n.times do
  count += check(checked_idx,arr)

  checked_idx.each do |chk|
    chk << chk.last+1
  end

  checked_idx.delete_at(-1)
  if checked_idx.empty?
    break
  end
end


puts count