let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()

module IntMap = Map.Make (struct 
  type t = int 
  let compare = compare
end)

let rec loop map i ans =
  if i = n then ans
  else
    let ans = ans + try IntMap.find (i - a.(i)) map with _ -> 0 in
    let k = i + a.(i) in
    let map = IntMap.add k (1 + try IntMap.find k map with _ -> 0) map in
    loop map (i + 1) ans

let () = Printf.printf "%d\n" @@ loop IntMap.empty 0 0