N = int(input())
A = list(map(int,input().split()))
B = []
ans = A.count(0)
B.append(A)
for i in range(1,N):
    B.append([ B[i-1][j] + B[0][j+1] for j in range(N -i) ])
    ans += B[i].count(0)
#print(B)
print(ans)