#include <bits/stdc++.h>
using namespace std;
int II() {
  int q;
  scanf("%d", &q);
  return q;
}
long long LII() {
  long long q;
  scanf("%lld", &q);
  return q;
}
const long long Mx = 200005;
long long N;
long long ar[Mx];
long long tree[Mx];
vector<long long> v[Mx];
void update(long long in, long long val) {
  while (in > 0) {
    tree[in] += val;
    in -= (in & (-in));
  }
}
long long query(long long in) {
  long long sum = 0;
  while (in < Mx) {
    sum += tree[in];
    in += (in & (-in));
  }
  return sum;
}
void solve() {
  cin >> N;
  for (long long i = 1; i <= N; i++) {
    cin >> ar[i];
    ar[i] = min(ar[i], N);
    v[ar[i]].push_back(i);
    update(i, 1);
  }
  long long ans = 0;
  for (long long i = 1; i <= N; i++) {
    if (ar[i] > i) {
      ans += query(i + 1) - query(ar[i] + 1);
    }
    for (auto it : v[i]) update(it, -1);
  }
  cout << ans << endl;
}
int32_t main() {
  long long tt;
  tt = 1;
  long long cas = 1;
  while (tt--) {
    solve();
  }
}
