#include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
long long n;
long long a[maxn], C[maxn];
vector<long long> vi[maxn];
long long lowbit(long long x) { return x & (-x); }
long long sum(long long x) {
  long long ret = 0;
  while (x > 0) {
    ret += C[x];
    x -= lowbit(x);
  }
  return ret;
}
void add(long long x) {
  while (x < maxn) {
    C[x]++;
    x += lowbit(x);
  }
}
void init() {
  memset(C, 0, sizeof(C));
  for (int i = 0; i < maxn; i++) vi[i].clear();
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n) {
    init();
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      a[i] = min(a[i], n);
      vi[min((long long)i - 1, a[i])].push_back((long long)i);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      add(a[i]);
      for (int j = 0; j < vi[i].size(); j++) {
        ans += sum(n) - sum(vi[i][j] - 1);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
