N=parse(Int64,readline())
A= parse.(split(readline()))

count=0
sum=zeros(Int64,N)
sum[1]=A[1]
for n in 2:N
    sum[n]+=sum[n-1]+A[n]
end
for i in 1:N
    if(sum[i]==0)
        count+=1
    end
end
for n in 2:N
    for i in 1:n-1
        if(sum[n]-sum[i]==0)
           count+=1
#            println(string(n)*","*string(i))
        end
    end
end

print(count)