#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
struct node {
  long long v, id;
} b[N];
long long t[N], a[N], n;
bool cmp(node a, node b) { return a.v < b.v; }
void add(long long x, long long d) {
  while (x <= n) {
    t[x] += d;
    x += x & (-x);
  }
}
long long query(long long x) {
  long long ans = 0;
  while (x) {
    ans += t[x];
    x -= x & (-x);
  }
  return ans;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    add(i, 1);
    b[i].v = a[i];
    b[i].id = i;
  }
  sort(b + 1, b + n + 1, cmp);
  long long pos = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += max(0ll, query(min(a[i], n)) - query(i));
    while (b[++pos].v <= i && pos <= n) add(b[pos].id, -1);
    pos--;
  }
  printf("%lld", ans);
  return 0;
}
