import std;

void main() {
	int n;
	scanf("%d\n", &n);
	auto as = readln.chomp.split.to!(int[]);
	long count = 0;
	foreach(i;0..as.length) {
		foreach(j;i..as.length) {
			if (as[i]+as[j] == j-i) {
				count += 1;
			}
		}
	}
	count.write;
}
