n = int(input())
list_a = list(map(int, input().split(" ")))

count = 0
for i in range(1, n + 1):
    for j in range(n - i + 1):
        if sum(list_a[j:j+i]) == 0:
            count += 1

print(count)
