N = int(input())
A = list(map(int, input().split()))

left = []
right = []
for i in range(N):
    for j in range(i, N):
        #print(i,j)
        if sum(A[i:j+1])==0:
            #print(A[i:j+1])
            left.append(i)
            right.append(j)
            break

ans = len(left)

chain = []
ids = list(range(len(left)))
for i in range(len(left)):
    if i in ids:
        id = i
    else:
        continue
    tmp = [id]
    while True:
        R = right[id]
        ids.remove(id)
        if R+1 in left[id+1:]:
            id = left.index(R+1, id+1)
            tmp.append(id)
        else:
            break
    if len(tmp)>1:
        chain.append(tmp[:])

#print(chain)
for i in range(len(chain)):
    N = len(chain[i])
    ans += N*(N-1)//2

print(ans)
