import itertools
n = int(input())
m = list(map(int,input().split()))

c=0
for i in range(2,n-1):
    for l in range(0,n-i+1):
        ki = m[l:l+i]
        if sum(ki)==0:
            c +=1
        else:
            c=c
print(c)