fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val map = mutableMapOf<Int, Long>()
    println(a.mapIndexed { idx, v ->
        map[-v - idx] = map.getOrDefault(-v - idx, 0L) + 1
        map.getOrDefault(v - idx, 0L)
    }.sum())
}