#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N];
int f[N];
int n;
void add(int x, int val) {
  for (; x <= n; x += x & (-x)) {
    f[x] += val;
  }
}
int query(int x) {
  int sum = 0;
  for (; x >= 1; x -= x & (-x)) {
    sum += f[x];
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  set<pair<int, int>> p;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = min(a[i], n);
    int tmp = query(a[i]);
    ans += tmp;
    if (a[i] > i) {
      add(i, 1);
      p.insert(make_pair(a[i], i));
    }
    while (p.size()) {
      auto v = *p.begin();
      if (v.first <= i) {
        add(v.second, -1);
        p.erase(p.begin());
      } else {
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
