{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
-- see: https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html
import           Data.Map.Strict                ( Map )
import qualified Data.Map.Strict               as Map
import           Data.IntMap                    ( IntMap )
import qualified Data.IntMap                   as IntMap


main :: IO ()
main = do
  n  <- readLn @Int
  as <- VU.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let xs = hist $ VU.toList $ VU.zipWith (-) (VU.enumFromN 1 n) as
  let ys = hist $ VU.toList $ VU.zipWith (+) (VU.enumFromN 1 n) as
  print $ sum $ IntMap.elems $ IntMap.intersectionWith (*) xs ys
-- create histogram from list
hist :: [Int] -> IntMap Int
hist xs = IntMap.fromListWith (+) $ zip xs $ repeat 1
