import java.util.*

fun main() {
    val sc = Scanner(System.`in`)

    // j > i

    // ai + aj = j - i
    // ai + i = j - aj
    val n = sc.nextInt()
    val arr = LongArray(n+1)
    val m = HashMap<Long,Int>()
    for(i in 1..n) {
        arr[i] = sc.nextLong()
        val d = i - arr[i]
        m[d] = (m[d]?:0) + 1
    }
    var ans = 0L
    for(i in 1..n) {
        val d = i + arr[i]
        ans += m[d]?:0
    }
    print(ans)
}