import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n = sc.nextInt()
    val as = Vector.fill(n)(sc.nextInt())

    val plus = as.zipWithIndex.map {
      case (height, index) => height + index + 1
    }

    val minus = as.zipWithIndex.map {
      case (height, index) => index + 1 - height
    }

    var mapPlus = Map[Int, Int]()
    var mapMinus = Map[Int, Int]()

    plus.foreach(i => mapPlus = mapPlus + (i -> (mapPlus.getOrElse(i, 0) + 1)))
    minus.foreach(
      i => mapMinus = mapMinus + (i -> (mapMinus.getOrElse(i, 0) + 1))
    )

    var ans = 0L

    mapPlus.foreach {
      case (x, amount) => ans += amount * mapMinus.getOrElse(x, 0)
    }

    println(ans)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

}
