N = int(input())
A = list(map(int, input().split()))
count = 0

for i in range(N-1):
    if sum(A[i:]) == 0:
        count += 1
    B = A[i:]
    for j in range(2, N-i):
        if sum(B[:j]) == 0:
            count += 1

print(count)