# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N

for i in range(N):
    l[i]=l[i-1]+A[i]


ans=l.count(0)
for i in range(N):
    for j in range(i):
        if l[i]==l[j]:
            ans+=1

print(ans)

