local n=io.read("n")
local sum=0
local map={[0]=1}
for i=1,n do
    sum=sum+io.read("n")
    map[sum]=(map[sum] or 0)+1
end

local counter=0
for k,v in pairs(map) do
    counter=counter+v*(v-1)//2
end
print(counter)