#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
struct data {
  int id, w;
} d[N];
bool cmp(data A, data B) { return A.w < B.w; }
int tr[N];
int lower(int x) { return x & (-x); }
void upd(int x, int k) {
  for (; x < N; x += lower(x)) tr[x] += k;
}
int get(int x) {
  int ans = 0;
  for (; x; x -= lower(x)) ans += tr[x];
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    d[i].id = i, d[i].w = a[i];
  }
  sort(d + 1, d + 1 + n, cmp);
  for (int i = 1; i <= n; ++i) upd(i, 1);
  long long ans = 0;
  int lt = 1;
  for (int i = 1; i <= n; ++i) {
    if (a[i] > i) {
      long long gg = get(min(a[i], n)) - get(i);
      ans += gg;
    }
    while (lt <= n && d[lt].w <= i) {
      if (d[lt].id > i) upd(d[lt].id, -1);
      lt++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
