const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const rows = input.split('\n')
    const N = rows[0] - 0
    const A = rows[1].split(' ').map(Number)

    const d = []
    for (let i = 0; i < N; i++) {
        if (d[i - A[i]]) {
            d[i - A[i]].push(i)
        } else {
            d[i - A[i]] = [i]
        }
    }

    let count = 0
    for (let i = 0; i < N; i++) {
        if (d[i + A[i]]) {
            count += d[i + A[i]].length
        }
    }
    
    console.log(count)

})(input)
