#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> t[4 * N];
int a[N];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = vector<int>(1, a[tl]);
  } else {
    int tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    merge(t[v * 2].begin(), t[v * 2].end(), t[v * 2 + 1].begin(),
          t[v * 2 + 1].end(), back_inserter(t[v]));
  }
}
int query(int v, int tl, int tr, int l, int r, int x) {
  if (l > r) return 0;
  if (l == tl && r == tr) {
    long long int temp =
        lower_bound(t[v].begin(), t[v].end(), x) - t[v].begin();
    temp = t[v].size() - temp;
    return temp;
  }
  int tm = (tl + tr) / 2;
  return query(v * 2, tl, tm, l, min(r, tm), x) +
         query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
}
void solve() {
  int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int left = i + 1;
    long long int right = min(n, a[i]);
    ans += query(1, 1, n, left, right, i);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
}
