import qualified Data.Sequence as S

toInt x = read x :: Int

check :: [Int] -> S.Seq Int -> Int
check [] _ = 0
check [_] _ = 0
check (x:xs) ys = length (S.findIndicesL (==x) ys) + check xs ys

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