#include <bits/stdc++.h>
const int N = 200005;
int A[N], B[N], T[N << 1], n;
long long ans;
std::vector<int> V[N];
int lowbit(const int &x) { return x & -x; }
void add(int l, const int &v) {
  while (l <= n) T[l] += v, l += lowbit(l);
}
int query(int r) {
  int a = 0;
  while (r) a += T[r], r -= lowbit(r);
  return a;
}
int main() {
  std::cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", A + i);
    if (A[i] > n) A[i] = n;
    ans += query(A[i]);
    if (A[i] > i) add(i, 1), V[A[i]].push_back(i);
    for (int j = 0; j < (int)V[i].size(); ++j) add(V[i][j], -1);
  }
  return !printf("%lld\n", ans);
}
