main(){
int i,n,a[200002],b[200002]={0};
long long c=0;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++){
	if(i+a[i]<=n)b[i+a[i]]++;
	if(i-a[i]>=0)c+=b[i-a[i]];
}
printf("%lld",c);
}