#include <bits/stdc++.h>
using namespace std;
long long a[2 * 100000 + 1];
vector<long long> tree[4 * 200000 + 1];
long long query(long long index, long long l, long long r, long long left,
                long long right, long long x) {
  if (left > r || right < l || l > r) return 0;
  if (left <= l && right >= r) {
    long long ind = lower_bound(tree[index].begin(), tree[index].end(), x) -
                    tree[index].begin();
    return tree[index].size() - ind;
  } else {
    long long mid = (l + r) >> 1;
    long long p = query(2 * index, l, mid, left, right, x);
    long long q = query(2 * index + 1, mid + 1, r, left, right, x);
    return p + q;
  }
}
void build(int index, int l, int r) {
  if (l == r) {
    tree[index].push_back(a[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(2 * index, l, mid);
  build(2 * index + 1, mid + 1, r);
  merge(tree[index * 2].begin(), tree[index * 2].end(),
        tree[index * 2 + 1].begin(), tree[index * 2 + 1].end(),
        back_inserter(tree[index]));
}
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long l = i + 1;
    long long r = min(n, a[i]);
    ans = ans + query(1, 1, n, l, r, i);
  }
  cout << ans << endl;
  return 0;
}
