import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N) {
    A(i) = in.next().toInt
  }

  val iA = new Array[Int](N+1)
  val jA = new Array[Int](N+1)
  for (i <- 1 to N) {
    iA(i) = i + A(i)
    jA(i) = i - A(i)
  }

  val hash = Map[Int, Int]()
  for (i <- 1 to N) {
    val now = jA(i)
    if (hash.contains(now))
      hash(now) += 1
    else
      hash += (now->1)
  }


  var ans = 0L
  for (i <- 1 to N) {
    val now = iA(i)
    hash(jA(i)) -= 1

    if (hash.contains(now))
      ans += hash(now)
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
