from numba.decorators import jit
N=int(input().rstrip())
A=list(map(int, input().rstrip().split())) #input parameters
#start= time.time()
count=int()
#for i,j in itertools.combinations(range(0,N+1),2):
#    if sum(A[i:j])==0:
#        count+=1
#for i in range(0,N):
#    work=int(0)
#    for j in range(i,N):
#        work+=A[j]
#        if work==0:
#            count+=1
@jit
def countfori(i):
    work=int(0)
    countfori=int()
    for j in range(i,N):
        work+=A[j]
        if work==0:
            countfori+=1
    return countfori
for i in range(0,N):
    count+=countfori(i)
print(count)