import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val heights: Array[Int] = (0 +: (1 to n).map { _ => sc.nextInt() }).toArray
  var result = 0
  for {
    i <- 1 to n
    j <- i to n
    if math.abs(i - j) == heights(i) + heights(j)
  } result += 1
  println(result)
}
