def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:
        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

arr=[int(arr_data[1][x] )for x in range(n)]

cnt=0
for i in range(0,n):
    
    for j in range(i+2,n+1):
        
        if sum(arr[i:j])==0:
            
            cnt+=1
            
print(cnt)
        