fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val plus = aa.mapIndexed { idx, i -> idx + i }.groupBy { it }
    val minus = aa.mapIndexed { idx, i -> idx - i }.groupBy { it }

    var cnt = 0L

    plus.entries.forEach {
        val p1 = it.value.size
        val p2 = minus[it.key]?.size ?: 0
        cnt += p1.toLong() * p2.toLong()
    }

    println(cnt)
}