#include <bits/stdc++.h>
using namespace std;
long long ans;
int n, now, a[200035], f[200035];
struct node {
  int a, i;
} p[200035];
bool cmp(node x, node y) { return x.a < y.a; }
int lowbit(int x) { return x & -x; }
void ins(int x, int c) {
  for (; x <= n + 1; x += lowbit(x)) f[x] += c;
}
int query(int x) {
  int ret = 0;
  for (; x; x -= lowbit(x)) ret += f[x];
  return ret;
}
int main() {
  scanf("%d", &n);
  now = 1;
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), a[i] = min(a[i], n + 1), p[i].a = a[i], p[i].i = i,
                        ins(i, 1);
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    while (now <= n && p[now].a < i) ins(p[now++].i, -1);
    ans += query(a[i]);
    if (a[i] >= i) ans--;
  }
  cout << ans / 2 << endl;
  return 0;
}
