n = gets.to_i
nums = gets.chomp.split(" ")
nums.map!{ |num| num = num.to_i}
count = 0
for i in 0..n - 1
    sum = 0
    for j in 0..n - i - 1
        sum += nums[j]
        if sum == 0
            count += 1
        end
    end
end
puts count