import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

immutable int INF = 1 << 29;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto seppen = new long[](N);
    foreach (i; 0..N) seppen[i] = A[i] - i;

    int[long] cnt;
    foreach (a; seppen) cnt[a] += 1;

    long ans = 0;
    foreach (i, a; A) {
        long b = -2 * i.to!long - seppen[i];
        if (b in cnt) ans += cnt[b];
    }

    ans.writeln;
}
