n,*q=map(int,open(0).read().split())
ans=0
for t in range(2,n):
    for s in range(n):
        try:
            if s+t>n:
                break
   #         print(q[s:s+t])
            if sum(q[s:s+t])==0:
                ans+=1
        except:
            break
print(ans)