N = gets.to_i
a = []
gets.split(" ").each{|v| a << v.to_i}
count = 0
for i in (2..N) do
    for j in (0...N) do
        break if (j+i) >= (N+1)
        sum = 0
        for k in (j...(j+i)) do
            sum += a[k]
        end
        if sum == 0 then
            count += 1
        end
    end
end

print count