N = int(input())
A = list(map(int, input().split()))

sums = [[None for j in range(N-i)] for i in range(N)]

for i in range(N):
    for j in range(N-i):
        if j == 0:
            sums[i][j] = A[i]
        else:
            sums[i][j] = sums[i][j-1] + A[j+i]

count = 0
for line in sums:
    count += line.count(0)
    
print(count)