// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_e
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n = readln.chomp.to!int;

    int[] a = readln.split.map!(to!int).array;

    int[] y = new int[1000000005];

    foreach(idx; 0..n) {
        int x = idx+1+a[idx];
        y[x] += 1;
    }

    int answer = 0;
    foreach(i; 0..n) {
        int x = i+1-a[i];
        if(x >= 0 && y[x] > 0)
            answer += y[x];
    }

    answer.writeln;
}
