#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int cmp(long *b1, long *b2){ // 昇順
    if(*b1 > *b2) return 1;
    else if(*b1 < *b2) return -1;
    else return 0;
}



int main(){
  int n;
  scanf("%d",&n);
  long a[n];
  long ai[n];
  long aj[n];
  F(i,0,n){
    scanf("%ld",a+i);
    ai[i]=a[i]+i+1;
    aj[i]=i+1-a[i];
  }
  qsort(ai,n,sizeof(long),cmp);
  qsort(aj,n,sizeof(long),cmp);
  int i=0,j=0;
  long ans=0;
  while(i+1<n && j<n){
    long tmpi=1,tmpj=0;
    while(ai[i]==ai[i+1] && i+1<n){
      tmpi++;
      i++;
    }
    while(ai[i]!=aj[j] && ai[i]>aj[j] && j<n) j++;
    while(ai[i]==aj[j] && j<n){
      tmpj++;
      j++;
    }
    ans += tmpi*tmpj;
    i++;
  }
  printf("%ld\n",ans);
  return 0;
}