#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int n, tmp;
	long long ans;
	ans = 0;
	int *a;
	
	scanf("%d", &n);
	a = (int*)calloc(n+1, sizeof(int));
	for(int i = 1;i < n + 1;i++)
	{
		scanf("%d", &tmp);
		if(tmp+i<n)a[i+tmp]++;
		if(i>tmp) ans += (long long)a[i-tmp];
	}
	printf("%lld\n", ans);
	free(a);
	return 0;
}