"use strict";

// read lines from stdin
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const N = parseInt(input[0], 10);

const heightList = input[1].split(" ").map((val) => parseInt(val, 10));

let result = 0;

for (let i = 0; i < N - 1; i++) {
  for (let j = i + 1; j < N; j++) {
    if (j - i === Math.abs(heightList[i] + heightList[j])) {
      result++;
    }
  }
}

console.log(result);
