
N = int(input())
ary = list(map(int, input().split(' ')))
count = 0
for i in range(1,N+1):
    for j in range(N):
        if j + i > N: break
        if sum(ary[j:j+i]) == 0:
            count += 1
print(count)