import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.IntMap.Strict as IM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let ls = zipWith (+) [1..] as
        rs = zipWith (-) [1..] as
        ans = sum [ fromMaybe 0 $ m IM.!? l | l <- ls]
            where m = IM.fromListWith (+) $ zip rs [1,1..]
    print ans