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