N = int(input())
a = [int(i) for i in input().split()] #横にNこ
num = 0
for j in range(N):
    k = j + 1 
    while k < N+1:
        if (sum(a[j:k])==0):
            num = num + 1
        k = k+1
print(num)