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

counter = 0

for start in range(n):
    for end in range(start + 1, n + 1):
        if sum(a[start:end]) == 0:
            counter += 1

print(counter)