#include <bits/stdc++.h>
using namespace std;
int ep[200005];
int tree[1000000];
map<int, vector<int> > ep_s;
int find_sum(int l, int r, int size) {
  l = size / 2 - 1 + l;
  r = size / 2 - 1 + r;
  int total = tree[l];
  if (l < r) {
    total += tree[r];
    while ((l - 1) / 2 != (r - 1) / 2) {
      if (l % 2 == 1) total += tree[l + 1];
      if (r % 2 == 0) total += tree[r - 1];
      l = (l - 1) / 2;
      r = (r - 1) / 2;
    }
  }
  return total;
}
void make_tree(int index, int size) {
  if (index < (size / 2 - 1)) {
    make_tree(2 * index + 1, size);
    make_tree(2 * index + 2, size);
    tree[index] = tree[2 * index + 1] + tree[2 * index + 2];
  }
}
void del(int index, int size) {
  index = size / 2 - 1 + index;
  if (tree[index] != 0) {
    while (index != 0) {
      tree[index]--;
      index = (index - 1) / 2;
    }
    tree[0]--;
  }
}
int main() {
  int n;
  cin >> n;
  int deduct = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ep[i] = min(a - 1, n - 1);
    ep_s[ep[i]].push_back(i);
    if (i <= ep[i]) deduct++;
  }
  int size = 1;
  while (size < n) {
    size = size << 1;
  }
  size = size << 1;
  for (int i = 0; i < size; i++) {
    tree[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    tree[size / 2 - 1 + i] = 1;
  }
  make_tree(0, size);
  long long total = 0;
  for (int i = 0; i < n; i++) {
    total += find_sum(0, ep[i], size);
    map<int, vector<int> >::iterator it = ep_s.find(i);
    if (it != ep_s.end()) {
      vector<int> seasons = it->second;
      int sz = seasons.size();
      for (int i = 0; i < sz; i++) {
        del(seasons[i], size);
      }
    }
  }
  cout << (total - deduct) / 2 << endl;
  return 0;
}
