import qualified Data.Vector as V

toInt x = read x :: Int

check :: [Int] -> V.Vector Int -> Int
check [] _ = 0
check [_] _ = 0
check (x:xs) ys = length (V.filter (==x) ys) + check xs ys

main = do
    n <- toInt <$> getLine
    lst <- map toInt . words <$> getLine
    let lstA = zipWith (+) lst [1..]
        lstB = V.fromList $ zipWith (-) [1..] lst
    print $ check lstA lstB