N=int(input())
A=list(map(int,input().split()))
 
count=0
 
SUM=[A[0]]
 
for i in range(1,N):
    x=SUM[i-1]+A[i]
    SUM = SUM + [x]
 
    if x==0:
        count=count+1
 
    for j in range(i-1):
        if x==SUM[j]:
            count=count+1
 
 
print(count)