n=int(input())
A=list(map(int,input().split()))
x=0
lst=[]
for i in range(n):
    x+=A[i]
    lst.append(x)
ans=0

    
def conv(n,m):
    if n==m or m==0:
        return 1
    else:
        return conv(n-1,m-1)+conv(n-1,m)

for num in lst:
    x=lst.count(num)
    if x==0:
        break
    if x==1:
        if num==0:
            ans+=1
    elif num!=0:
        ans+=conv(x,2)
    elif num==0:
        ans+=x+conv(x,2)
    
    lst=[i for i in lst if i!=num]
    
    
    

print(ans)