#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const long long N = 2e5 + 300;
const long long M = 19;
struct FenwickTree {
  vector<long long> bit[N];
  long long n;
  void init(long long n) { this->n = n; }
  long long sum(long long r, long long x) {
    long long ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) {
      if (bit[r].size() == 0) continue;
      long long y =
          bit[r].end() - upper_bound((bit[r]).begin(), (bit[r]).end(), x - 1);
      ret += y;
    }
    return ret;
  }
  void add(long long idx, long long delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx].push_back(delta);
  }
  long long sum(long long l, long long r, long long x) {
    return sum(r, x) - sum(l - 1, x);
  }
} fw;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fw.init(N);
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    fw.add(i, a[i]);
  }
  for (long long i = 0; i < N; i++)
    sort((fw.bit[i]).begin(), (fw.bit[i]).end());
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long o = a[i] - i;
    if (o <= 0) continue;
    long long l = i + 1;
    long long r = l + o - 1;
    r = min(r, n);
    ans += fw.sum(l, r, i);
  }
  cout << ans;
}
