import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val as = in.readLine().split("\\s+").map(_.toInt)

    val map = mutable.HashMap.empty[Int, Int]

    for(i <- 0 until n) {
      val l = i + as(i) + 1
      map.update(l, map.getOrElseUpdate(l, 0) + 1)
    }

    var counter = 0L

    for(i <- 0 until n) {
      val r = i - as(i) + 1
      map.get(r) match {
        case Some(c) =>
          counter += c
        case None =>
      }
    }

    out.println(counter)
    out.flush()
  }
}
