n=int(input())
a=list(map(int,input().split()))
ans=0
accum = [0]*(n+1)
accum[0]=0
for i in range(n):
    accum[i+1]=a[i]+accum[i]

for number in range(1,n+1):
    for i in range(1,n+2-number):
        if(accum[number+i-1]-accum[i-1]==0):
            ans+=1
            
print (ans)