#include<stdio.h>
#include<stdlib.h>
//getchar_unlockedのテスト
void getnn(int* n)
{
	char c;
	do
	{
		c = getchar_unlocked();
	}while(c<'0'||'9'<c);
	while('0'<=c && c<='9')
	{
		*n = (*n * 10) + c - '0';
		c = getchar_unlocked();
	}
	return;
}
int main(void)
{
	int n, tmp;
	long long ans;
	ans = 0;
	int *a;
	
	getnn(&n);
	a = (int*)calloc(n+1, sizeof(int));
	for(int i=1; i<n+1; i++)
	{
		getnn(&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;
}
