object Main {

  def main(args: Array[String]): Unit = {

    val n = io.StdIn.readLine().toInt
    val participants = io.StdIn.readLine().split(" ").map(_.toInt)

    var count = 0

    for {
      i <- 0 until (n - 1)
      h1 = participants(i)
      j <- (i + h1 + 1) until n
    } {
      if(h1 + participants(j) == j - i) {
        count+=1
      }
    }

    println(count)

  }
}