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 

check :: [Int] -> [Int] -> Int
check [] base = 0
check (x:xs) base = length((filter (==0) $ map (+x) (zipWith (-) xs base))) + check xs base

main = do
    n <- toInt <$> getLine
    lst <- map toInt . words <$> getLine
    let base = [1..n]
    print $ check lst base