#include <bits/stdc++.h>
using namespace std;
vector<int> arr(200005);
vector<vector<int> > tree(800005);
void build(int idx, int l, int r) {
  if (l == r) {
    tree[idx].push_back(arr[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(idx << 1, l, mid);
  build(idx << 1 | 1, mid + 1, r);
  tree[idx].resize(tree[idx << 1].size() + tree[idx << 1 | 1].size());
  merge(tree[idx << 1].begin(), tree[idx << 1].end(),
        tree[idx << 1 | 1].begin(), tree[idx << 1 | 1].end(),
        tree[idx].begin());
}
long long query(int idx, int start, int end, int l, int r, int val) {
  if (start > r || end < l) return 0;
  if (l <= start && end <= r) {
    return tree[idx].end() -
           lower_bound(tree[idx].begin(), tree[idx].end(), val);
  }
  int mid = (start + end) >> 1;
  return query(idx << 1, start, mid, l, r, val) +
         query(idx << 1 | 1, mid + 1, end, l, r, val);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  build(1, 1, n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] > i) ans += query(1, 1, n, i + 1, arr[i], i);
  }
  cout << ans;
}
