import std;

long calc(long[] a) {
    long ans = 0;
    long[long] d;
    for (int i = 0; i < a.length; i++) {
        ans += d.get(i + 1 - a[i], 0);
        d[i + 1 + a[i]]++;
    }
    return ans;
}

void main() {
    read;
    auto a = reads!long;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;
