#include <stdio.h>
typedef long long ll;
typedef struct hoge{
    ll A;
    ll left;
    ll right;
}height;

int main(){
  ll N;
  ll ans=0;
  scanf("%lld",&N);
  height H[N];
  for(ll i = 0;i<N;i++){
    scanf("%lld",&H[i].A);
    H[i].left = i-H[i].A;
    H[i].right = i+H[i].A;
  }
  for(ll i = 0;i<N;i++) for(ll j = N-1;j>=0;j--) if(H[i].right == H[j].left) ans++;
  printf("%lld\n",ans);
  return 0;
}