toInt x = read x :: Int

-- pair :: [(Int,Int)] -> [((Int,Int),(Int,Int))]
-- pair lst = [(x,y) | x<- lst ,y<- lst, (abs ((fst x) - (fst y))) == ((snd x) + (snd y))]

-- check :: [(Int,Int)] -> [((Int,Int),(Int,Int))]
-- check [] = []
-- check [_] = []
-- check (x:xs) = (pair x xs) ++ (check xs)
--     where
--         pair :: (Int,Int) -> [(Int,Int)] -> [((Int,Int),(Int,Int))]
--         pair m ms = [(m,n) | n <- ms, (fst n) - (fst m) == ((snd m) + (snd n))]

mkComb :: [(Int,Int)] -> [((Int,Int),(Int,Int))]
mkComb [] = []
mkComb [_] = []
mkComb (x:xs) = [(x,y) | y <- xs] ++ mkComb xs

check :: ((Int,Int),(Int,Int)) -> Bool
check (x,y) = fst y - fst x == snd x + snd y 

main = do
    n <- getLine
    lst <- getLine
    let comb = mkComb $ zip [1..] (map toInt $ words lst)
    print $ length $ filter check comb