"use strict"
function main(arg) {
    const A = arg.trim().split("\n")[1].split(" ").map(Number)
    const N = A.length
    let counter = 0
    for (let i = 0; i < N; i++) {
        for (let j = i + 1; j < N; j++) {
            // console.log([i,j])
            let x = Math.abs(i-j)
            let y = A[i] + A[j]
            if (x === y) {
                counter++
            }
        }
    }
    console.log(counter)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));