"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const rows = input.trim().split("\n");

const N = Number(rows[0].trim());
const An = rows[1].trim().split(" ").map(Number);

const mapL = {};
const mapR = {};
for (let i = 0; i < N; i++) {
  const Ai = An[i];
  const L = i + 1 + Ai;
  mapL[L] = mapL[L] || 0;
  mapL[L]++;
  const R = i + 1 - Ai;
  mapR[R] = mapR[R] || 0;
  mapR[R]++;
}

let result = 0;
Object.keys(mapL).forEach((key) => {
  const L = mapL[key];
  const R = mapR[key] || 0;
  result += L * R;
});
console.log(result);
