N = int(input())
A = [int(i) for i in input().split()]
leng = len(A)


def zero(n,a,l):
    count = 0
    for i in range(l - n + 1):
        part = a[i:i +n]
        if sum(part) == 0:
            count = count + 1
    return count


count_1 = 0
for j in range(1, leng+1):
    count_1 = count_1 + zero(j,A,leng)

print(count_1)