import std;

void main() {
    auto N = readln.split[0].to!long;
    auto A = readln.split.to!(long[]);
    ulong[long] Aminus;
    foreach (j; 0 .. N) {
        if (j-A[j] !in Aminus) Aminus[j-A[j]] = 0;
        Aminus[j-A[j]]++;
    }
    ulong ans;
    foreach (i; 0 .. N) {
        if (A[i]+i !in Aminus) continue;
        ans += Aminus[A[i]+i];
    }
    writeln(ans);
}

