import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }
}

object Main extends App {
  import Helpers._

  val n = readInt
  val as = readIntLine

  var m = Map[Int, Int]()
  var ans = 0

  for (i <- 0 until n) {
    ans += m.getOrElse(i - as(i), 0)
    val x = i + as(i)
    m = m + (x -> (m.getOrElse(x, 0) + 1))
  }

  println(ans)
}

