#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int max_cal(int a,int b)
{
  if(a>=b) return a;
  else return b;
}
void main(void)
{
  ll n,m,ans=0;
  ll p=100200002;
  scanf("%lld",&n);
  ll a[n+1],b[n+1],c[n+1],d[p];
  for(ll i=0;i<p;i++) d[i]=0;
  for(ll i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    b[i]=i-a[i];
    c[i]=i+a[i];
    d[c[i]]++;
    if(b[i]>0){
     if(d[b[i]]>0) ans+=d[b[i]];
    }
  }
  /*int ans=0;
  for(int i=1;i<n;i++){
    for(int j=(i+1);j<=n;j++){
      if(c[i]==b[j]) ans++;
    }
  }*/

  printf("%lld",ans);


}