#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int bit[200006];
void update(long long int pos) {
  while (pos <= n) {
    bit[pos]++;
    pos += pos & (-pos);
  }
}
long long int query(long long int pos) {
  long long int sum = 0;
  while (pos > 0) {
    sum += bit[pos];
    pos -= pos & (-pos);
  }
  return sum;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long int a[n + 1];
  vector<pair<long long int, pair<long long int, long long int> > > v;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    v.push_back({a[i], {1, i}});
    v.push_back({i, {0, a[i]}});
  }
  sort(v.begin(), v.end());
  long long int ans = 0;
  for (long long int i = v.size() - 1; i >= 0; i--) {
    long long int val = v[i].first;
    long long int t = v[i].second.first;
    if (t == 1) {
      update(v[i].second.second);
    } else {
      ans += query(min(n, a[val]));
    }
  }
  for (long long int i = 1; i <= n; i++) {
    if (a[i] >= i) {
      ans--;
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}
