#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, t, a[200005], ans = 0;
vector<int> tree[800005];
void build(int node, int low, int high) {
  if (low == high) {
    tree[node].push_back(a[low]);
    return;
  }
  int mid = (low + high) / 2;
  build(2 * node, low, mid);
  build(2 * node + 1, mid + 1, high);
  merge((tree[2 * node]).begin(), (tree[2 * node]).end(),
        (tree[2 * node + 1]).begin(), (tree[2 * node + 1]).end(),
        back_inserter(tree[node]));
  return;
}
int query(int node, int low, int high, int l, int r, int val) {
  if (l > r) return 0;
  if (low > r || high < l) return 0;
  if (l <= low && high <= r)
    return tree[node].end() -
           lower_bound((tree[node]).begin(), (tree[node]).end(), val);
  int mid = (low + high) / 2;
  return query(2 * node, low, mid, l, r, val) +
         query(2 * node + 1, mid + 1, high, l, r, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  for (i = 1; i <= n; i++) {
    ans += query(1, 1, n, i + 1, min(a[i], n), i);
  }
  cout << ans << '\n';
  return 0;
}
