import qualified Data.Vector.Unboxed as U
import qualified Data.IntMap         as M

main :: IO ()
main = do
  n <- readLn
  as <- U.fromListN n . map read . words <$> getLine
  print $ solve as

solve :: U.Vector Int -> Int
solve as = M.foldr (+) 0 $ M.intersectionWith (*) lmp rmp
  where
    ls = U.imap (\i a -> i + a) as
    rs = U.imap (\i a -> i - a) as
    lmp = U.foldr (\x mp -> M.insertWith (+) x 1 mp) M.empty ls
    rmp = U.foldr (\x mp -> M.insertWith (+) x 1 mp) M.empty rs