import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val freq1 = mutableMapOf<Int, Long>()
    val freq2 = mutableMapOf<Int, Long>()
    val tokenizer = StringTokenizer(jin.readLine())
    for (j in 1..n) {
        val h = tokenizer.nextToken().toInt()
        freq1[j - h] = (freq1[j - h] ?: 0L) + 1L
        freq2[j + h] = (freq2[j + h] ?: 0L) + 1L
    }
    var answer = 0L
    for ((k, f) in freq1) {
        answer += f * (freq2[k] ?: 0L)
    }
    println(answer)
}