import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val NMax = 200000
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val heights = (1 to n).map { _ => sc.nextInt() }
  val ls = mutable.Map.empty[Int, Int].withDefaultValue(0)
  val rs = mutable.Map.empty[Int, Int].withDefaultValue(0)
  heights.zipWithIndex.foreach { case (h, i) =>
    val l = (i + 1) + h
    ls.put(l, ls(l) + 1)
    val r = (i + 1) - h
    rs.put(r, rs(r) + 1)
  }
  val result = ls.map { case (l, num) =>
    rs.getOrElse(l, 0) * num
  }.sum
  println(result)
}
