ide_ele = 0

def segfunc(x,y):
    return x+y

def init(init_val):
    for i in range(n):
        seg[i+num-1] = init_val[i]
    for i in range(num-2,-1,-1):
        seg[i] = segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1],seg[2*k+2])
    
def query(l,r):
    if r<l:
        return ide_ele
    l += num-1
    r += num-1
    res = ide_ele
    while r-l>1:
        if l&1 ==0:
            res = segfunc(res,seg[l])
        if r&1 == 1:
            res = segfunc(res,seg[r])
            r -=1
        l = l//2
        r = (r-1)//2
    if l==r:
        res = segfunc(res,seg[l])
    else:
        res = segfunc(segfunc(res,seg[l]),seg[r])
    return res

n = int(input())
a = list(map(int, input().split()))
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num
init(a)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if query(i,j)==0:
            ans +=1
print(ans)
