N = int(input())

A = [int(x) for x in input().split()]

#print(A)
Count = 0
for i in range(1,N+1):
    for j in range(N-i+1):
        seq = A[j:i+j]
        if sum(seq) == 0:
            #print("found")
            Count += 1

print(Count)
