#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> reach(n, 0);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i - a[i] >= 0) {
      ans += reach[i - a[i]];
    }
    if (i + a[i] < n) reach[i + a[i]]++;
  }
  cout << ans << endl;
}
