function E166(_input) {
    var lines = _input.split("\n");
    var num = lines.shift()*1;
    var heights = lines.shift().split(' ').map(item => item*1);
    var map = {};
    var count = 0;

    for (let i = 1; i<=num;i++) {
        var pk = i - heights[i-1];
        count += map[pk] ? map[pk] : 0;
        var nk = i + heights[i-1];
        map[nk] = map[nk] ? (map[nk]+1) : 1;
    }
    console.log(count);
}
E166(require("fs").readFileSync("/dev/stdin", "utf8"));