import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt()
  val a = StdIn.readLine().split(" ").map(_.toInt).zipWithIndex
  val map = a.map { case (x, ind) => (ind - x) -> ind }.groupBy(_._1).view.mapValues(_.map(_._2))
  val cnt = a.foldLeft(0)((acc, x) => acc + map.getOrElse(x._1 + x._2, Array.empty).length)
  println(cnt)

  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }
}