#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	int N; scanf("%d",&N);
	int minus[N],plus[N];
	int m=2001001001,M=0;
	rep(i,0,N){
		int a; scanf("%d",&a);
		minus[i] = i-a;
		plus[i] = i+a;
		m = min(m,minus[i]);
		M = max(M,plus[i]+1);
	}
	int *X = (int*)malloc(sizeof(int)*(M-m));
	rep(i,0,M-m) X[i]=0;
	llong ans=0;
	rep(i,0,N){
		ans += X[minus[i]-m];
		X[plus[i]-m]++;
	}
	printf("%lld",ans);
	return 0;
}
