fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val An = readLine()!!.split(" ").map(String::toInt)
    var count = 0L

    val acc_left_map: MutableMap<Int, Long> = mutableMapOf()
    val acc_right_map: MutableMap<Int, Long> = mutableMapOf()

    An.indices.map { 
        it - An[it]
    }.forEach { 
        acc_left_map[it] = acc_left_map.getOrDefault(it, 0L) + 1

    }
    An.indices.map { 
        it + An[it]
    }.forEach { 
        acc_right_map[it] = acc_right_map.getOrDefault(it, 0L) + 1
    }

    acc_left_map.keys.union(acc_right_map.keys).map { (acc_left_map[it]?: 0L) * (acc_right_map[it]?: 0L)}.fold(0L) {a, b -> a+b}.run(::println)

 }