"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);

let result = 0;
for (let i = 0; i < N; i++) {
  const Ai = An[i];
  for (let j = N - 1; j > Ai + i; j--) {
    const Aj = An[j];
    if (j - i === Aj + Ai) {
      result++;
    }
  }
}

console.log(result);
