import std.stdio: writeln, readln;
import std.conv: to;
import std.string: chomp;
import std.array: array, split;
import std.math: abs;
import std.algorithm: map;

void main() {
	int n = readln.chomp.to!int;
	int[] a = readln.split.map!(to!int).array;

	int[] x = new int[n];
	int[] y = new int[n];

	for (int i; i < n; i++) {
		x[i] = i+a[i];
		y[abs(i-a[i])] += 1;
	}

	int ans = 0;
	foreach (int i; x) {
		ans += y[i];
	}
	ans.writeln;
}
