import functools
import operator


N = int(input())
a = list(map(int, input().split()))
s = 0
for max_num in range(2, N + 1):
    for index in range(N - max_num + 1):
        subset = functools.reduce(operator.add, a[index: index + max_num])
        if 0 == subset:
            s += 1

print(s)