#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
const int MAX = 2e5 + 10;
int A[MAX];
int B[MAX];
struct nodo {
  int l, r, v;
};
nodo S[5 * MAX];
deque<ii> V;
void build(int i, int l, int r) {
  S[i].l = l;
  S[i].r = r;
  if (l == r) {
    S[i].v = B[l];
    return;
  }
  build(2 * i, l, (l + r) / 2);
  build(2 * i + 1, (l + r) / 2 + 1, r);
  S[i].v = S[2 * i].v + S[2 * i + 1].v;
}
int query(int i, int l, int r) {
  int L = S[i].l, R = S[i].r;
  if (l <= L && r >= R) return S[i].v;
  if (l <= (L + R) / 2 && r >= (L + R) / 2 + 1)
    return query(2 * i, l, r) + query(2 * i + 1, l, r);
  if (l <= (L + R) / 2) return query(2 * i, l, r);
  return query(2 * i + 1, l, r);
}
void change(int i, int p, int v) {
  int L = S[i].l, R = S[i].r;
  if (L == R) {
    S[i].v = v;
    return;
  }
  if (p <= (L + R) / 2)
    change(2 * i, p, v);
  else
    change(2 * i + 1, p, v);
  S[i].v = S[2 * i].v + S[2 * i + 1].v;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    V.push_back(ii(A[i], i));
    B[i] = 1;
  }
  sort(V.begin(), V.end());
  build(1, 1, n);
  ll res = 0;
  for (int i = 2; i <= n; i++) {
    while (!V.empty()) {
      ii par = V.front();
      int p = par.second;
      int eps = par.first;
      if (eps < i) {
        V.pop_front();
        B[eps] = 0;
        change(1, p, 0);
      } else
        break;
    }
    res += query(1, 1, min(i - 1, A[i]));
  }
  printf("%lld\n", res);
}
