import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L
import qualified Data.Set as S
import qualified Control.Monad as M
import Data.Maybe (fromJust)
import Data.Ord
import qualified Data.Vector.Unboxed as V


comb n x
 | n /= x = [(x,k) | k <- [x+1..n]] : comb n (x+1)
 | n == x = []
main = do
 n <- readLn :: IO Int
 list <- V.fromList <$> map (fst.fromJust.BS.readInt) <$> BS.words <$> BS.getLine
 print $sum$ map ( length.filter (==True). map (checker list))  $ comb n 1


checker list (a,b) = (list V.!(a-1)) + (list V.!(b-1)) == abs (a-b)