#include <bits/stdc++.h>
#pragma G++ optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007, logn = 20;
int b[200200], bit[200200];
struct node {
  int x, id;
} a[200200];
int n;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
void add(int x, int t) {
  for (; x <= n + 1; x += x & -x) bit[x] += t;
}
int query(int x) {
  int sum = 0;
  for (; x > 0; x -= x & -x) sum = (sum + bit[x]) % mod;
  return sum;
}
bool cmp(node a, node b) { return a.x < b.x; }
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i].x = min(n + 1, read());
    b[i] = a[i].x;
    a[i].id = i;
    add(i, 1);
  }
  sort(a + 1, a + n + 1, cmp);
  int pos = 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    while (pos <= n && a[pos].x < i) add(a[pos++].id, -1);
    ans += query(b[i]);
    if (b[i] >= i) ans--;
  }
  printf("%I64d\n", ans / 2);
  return 0;
}
