#include <stdio.h>

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int L[200001] = {}, R[200001] = {};
	long long ans = 0;
	for (i = 1; i <= N; i++) {
		if (i - A[i] >= 1) L[i-A[i]]++;
		if (i + A[i] <= N) R[i+A[i]]++;
	}
	for (i = 1; i <= N; i++) ans += (long long)L[i] * R[i];
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}