#include <bits/stdc++.h>
using namespace std;
long long int tree[1000000];
long long int a[1000000];
vector<long long int> vec[1000000];
void update(int idx, int k, int lo, int hi, int node) {
  long long int mid = (lo + hi) / 2;
  if (lo == hi) {
    tree[node] += k;
    return;
  }
  if (idx <= mid) {
    update(idx, k, lo, mid, 2 * node);
  } else {
    update(idx, k, mid + 1, hi, 2 * node + 1);
  }
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
long long int query(int l, int r, int lo, int hi, int node) {
  long long int mid = (lo + hi) / 2;
  if (l <= lo && r >= hi) return tree[node];
  if (hi < l) return 0;
  if (lo > r) return 0;
  if (l > lo || r < hi)
    return query(l, r, lo, mid, 2 * node) +
           query(l, r, mid + 1, hi, 2 * node + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, s, n;
  cin >> n;
  s = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = min(a[i], n);
    if (a[i] >= i) s--;
    vec[a[i]].push_back(i);
  }
  for (i = 1; i <= n; i++) {
    update(i, 1, 1, n, 1);
  }
  for (i = 1; i <= n; i++) {
    s += query(1, a[i], 1, n, 1);
    for (j = 0; j < vec[i].size(); j++) {
      update(vec[i][j], -1, 1, n, 1);
    }
  }
  cout << s / 2 << endl;
}
