# 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 + 1):
    for end in range(start, N + 1):
        if sum(A[start:end]) == 0 and len(A[start:end]) != 0:
            count += 1

print(count)