// https://atcoder.jp/contests/abc166/tasks/abc166_e

fun main() {
    abc166e()
}

fun abc166e() {
    val n = readLine()!!.toInt()
    val height = readLine()!!.split(" ").map { it.toLong() }
    var count = 0L
    val plus = mutableMapOf<Long, Long>()
    val minus = mutableMapOf<Long, Long>()
    for ((i, v) in height.withIndex()) {
        val p = i.toLong() + 1L + v
        val m = i.toLong() + 1L - v
        plus[p] = plus.getOrDefault(p, 0L) + 1L
        minus[m] = minus.getOrDefault(m, 0L) + 1L
    }
    for ((key, value) in plus) {
        count += (minus.getOrDefault(key, 0L) * value)
    }
    println(count)
}
