#include<stdio.h>

int main(void)
{
	unsigned long long int N, c;
	unsigned long long int A[200000];
	unsigned long long int sum = 0;
	unsigned long long int i, j;

	scanf("%ld", &N);

	for (i = 0; N > i; i++) {
		scanf("%ld", &(A[i]));
	}

	for (i = 0; N - 1 > i; i++) {
		for (j = i + 1; N > j; j++) {
			if (((j - i) == (A[j] + A[i])) || ((i - j) == (A[j] + A[i]))) {
				sum++;
			}
		}
	}

	printf("%lld", sum);

	return 0;
}