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

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


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


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