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

s = [0]
for i in 0..(n-1)
    s[i+1] = a[i] + s[i]
end

h = Hash.new(0)

s.each do |v|
    h[v] += 1
end

ans = 0
h.each do |k, v|
    next if v == 1
    ans += v * (v-1) / 2
end