#include<bits/stdc++.h>

using namespace std;

int main(void){
  map<long long, long long> s;
  long long ans = 0;
  long long N;
  cin >> N;
  for(long long i = 1; i <= N; i++){
    long long A;
    cin >> A;
    ans += s[i - A];
    s[i + A]++;
  }
  cout << ans << endl;
  return 0;
}
