import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val n = readInputLine().toLong()
    val aArr = readInputLine().split(" ").map { it.toLong() }

    val cnt = mutableMapOf<Long, Long>()

    var ans = 0L

    for (i in 0 until n.toInt()) {
        val tmp = aArr[i] - (i + 1).toLong()
        ans += cnt[tmp] ?: 0L

        val addTmp = -aArr[i] - (i + 1).toLong()
        cnt[addTmp] = (cnt[addTmp] ?: 0L) + 1L
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}
