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