#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

ll n;
ll a[200001];
int yoso[1000200001]={};


int main(){
  scanf("%lld",&n);
  ll sum=0;
  for(ll i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    if(i>a[i]){
      sum+=yoso[i-a[i]];}
    yoso[i+a[i]]++;}
  printf("%lld\n",sum);


  //printf("%lld %lld\n",a,b);
  
  return 0;
}
