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))]

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