n = int(input())
alist = [int(x) for x in input().split()]
ans = 0
for k in range(1,n+1):
    for i in range(n):
        if i+k <= n:
            #print(i+k,sum(alist[i:i + k]))
            if sum(alist[i:i+k]) == 0:
                ans += 1
print(ans)