#include <bits/stdc++.h>
using namespace std;
int n, a[200005], t[200005];
vector<pair<int, int> > rem;
void add(int x, int v) {
  while (x <= n) {
    t[x] += v;
    x += (x & -x);
  }
}
int query(int x) {
  int res = 0;
  while (x > 0) {
    res += t[x];
    x &= x - 1;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    rem.push_back({a[i], i});
    add(i, 1);
  }
  sort(rem.begin(), rem.end());
  int ind = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    while (ind < n && rem[ind].first < i) {
      add(rem[ind].second, -1);
      ++ind;
    }
    ans += (query(min(a[i], n)) - query(min(i, min(a[i], n))));
  }
  cout << ans;
}
