#include <bits/stdc++.h>
using namespace std;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(long long &x, long long y) {
  if (x > y) x = y;
}
inline long long read() {
  char s;
  long long k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) {
    k = k * 10 + (s ^ '0');
    s = getchar();
  }
  return k * base;
}
inline void write(int x) {
  static char cnt, num[15];
  cnt = 0;
  if (!x) {
    putchar('0');
    return;
  }
  for (; x; x /= 10) num[++cnt] = x % 10;
  for (; cnt; putchar(num[cnt--] + 48))
    ;
}
const int maxn = 2e5 + 100;
int t[maxn], a[maxn], n;
void xg(int x, int y) {
  while (x <= n) {
    t[x] += y;
    x += x & (-x);
  }
}
int qsum(int x) {
  int sum = 0;
  while (x) {
    sum += t[x];
    x -= x & (-x);
  }
  return sum;
}
vector<int> G[maxn];
vector<int> b[maxn];
long long ans;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] > n) a[i] = n;
    b[a[i]].push_back(i);
    if (a[i] >= i) ans--;
  }
  for (int i = 1; i <= n; i++) {
    xg(1, 1);
    xg(a[i] + 1, -1);
    for (int j = b[i].size() - 1; j >= 0; j--) {
      ans += qsum(b[i][j]);
    }
  }
  cout << ans / 2 << " ";
}
