n=int(input())
a=list(map(int,input().split()))

#累積和
ans=0
acum=[]
acumi=0
for i in range(n):
    acumi+=a[i]
    acum.append(acumi)
ans+=acum.count(0)
#print(a)
#print(acum)
i_ans=0
for i in range(n):
    i_ans+=a[i]
    ans+=acum[i+1:].count(i_ans)
#    print(ans,i_ans,acum[i+1:])
print(ans)
