toInt x = read x :: Int

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

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

main = do
    n <- toInt <$> getLine
    lst <- map toInt . words <$> getLine
    let lst' = zip [1..] lst
    print $ length $ filter check $ mkPair lst'