n = int(input())
sample = list(map(int, input().split()))
count = sample.count(0)

if sum(sample) == 0:
    count += 1

for i in range(n):
    for j in range(1, n-i+1):
        if sum(sample[i:i+j]) == 0:
            count += 1

print(count)