"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;

main();

function main() {
    //console.log(cin);
    //   cin = cin.map(i => +i);
    let n = +cin.shift();
    let B = {};
    let C = {};
    cin.forEach((v, i) => {
        let x = Number(v);
        B[String(i + 1 + x)] = B[String(i + 1 + x)] + 1 || 1;
        C[String(i + 1 - x)] = C[String(i + 1 - x)] + 1 || 1;
    });
    //console.log({ B, C })
    let keys = Object.keys(B);
    let ans = 0;
    keys.filter(i => C[i]).forEach(i => {
        ans += (B[i] * C[i]);
        //console.log(i, B[i], C[i]);
    });


    console.log(ans);
}