# AGC 023: A – Zero-Sum Ranges
N = int(input())
A = [int(s) for s in input().split()]

count = 0

for start in range(0, N):
    for end in range(start + 1, N + 1):
        #print(start, end, A[start:end], sum(A[start:end]))
        if sum(A[start:end]) == 0:
            count += 1
print(count)