#include <bits/stdc++.h>
using namespace std;
long long n, k, a[200005];
long long bit[200005 + 1];
long long sum(long long i) {
  long long s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(long long i, long long x) {
  while (i < 200005) {
    bit[i] += x;
    i += i & -i;
  }
}
vector<long long> G[200005];
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    if (a[i] > 200000) a[i] = 200001;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += sum(a[i]);
    if (a[i] > i) {
      add(i, 1);
      G[a[i]].push_back(i);
    }
    for (long long j = 0; j < G[i].size(); j++) add(G[i][j], -1);
  }
  printf("%I64d\n", ans);
  return 0;
}
