#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  map<ll, vector< ll > > kei;
  for(ll i = 1; i<=N; i++){
    cin >> A.at(i);
    if(i - A.at(i) >= 0){
      ll buf = i - A.at(i);
      if(kei.find(buf) ==kei.end() ){
        vector<ll> bb(1, i);
        kei.insert(buf, bb);
      }else{
        kei.at(buf).push_back(i);
      }
    }
  }

  ll count =0;

  for(int i = 0; i<=N; i++){
    ll keisan = i + A.at(i);
    if(kei.find(keisan) != kei.end()){
      vector<ll> koho - kei.at(keisan);
      for(ll k : koho){
        if(i > k){
          count++;
        }
      }
    }
  }

  cout << count <, endl;

  


}