#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int ord[N], n, a[N], c[N];
int lowbit(int x) { return x & -x; }
void add(int x, int y) {
  for (; x <= n; x += lowbit(x)) c[x] += y;
}
int sum(int x) {
  int s = 0;
  for (; x; x -= lowbit(x)) s += c[x];
  return s;
}
bool cmp(int i, int j) { return a[i] > a[j]; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = min(a[i], n);
    ord[i] = i;
  }
  sort(ord + 1, ord + n + 1, cmp);
  int j = 1;
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    while (j <= n && a[ord[j]] >= i) {
      add(ord[j], 1);
      j++;
    }
    if (i <= a[i]) ans += sum(a[i]) - sum(i);
  }
  printf("%lld\n", ans);
  return 0;
}
