n =gets.to_i
as=gets.strip.split(/ /).collect{|x| x.to_i}
ts=[0]
n.times{|i|
    ts<<(ts[-1]+as[i])
}
ts.sort!
ts<<'end'
def c(n)
    if n>1
        n*(n-1)/2
    else
        0
    end
end
t=ts[0]
i=0
sum=0
(1..(n+2)).times{|j|
if ts[j]!=t
    sum+=c(j-i)
    i=j
    t=ts[j]
end
}
puts sum
