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([])
    for j in range(N- i):
        B[i].append(B[i-1][j] + B[0][j+i])
        if B[i][j] == 0:
            ans += 1
#print(B)
print(ans)


