N = gets.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)

(0...N).each{|i|
    sum = 0
    (i...N).each{|j|
        sum += a[j]
        h[a.slice(i..j)] += 1 if sum == 0
    }
}

p h.values.inject(:+)