from numpy import array as arr
N = int(input())
a = arr(list(map(int,input().split())))
n = 0
for i in range(1,N+1):
    for j in range(N+1-i):
        if a[j:j+i].sum() == 0:
            n += 1
print(n)