#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int _w;
int n, a[N];
namespace PSGT {
struct Node {
  int cnt;
  Node *lc, *rc;
};
Node *rt[N], *nul;
int ql, qr;
Node *ins(Node *o, int L, int R, int v) {
  o = new Node(*o);
  ++o->cnt;
  if (L == R) return o;
  int M = (L + R) / 2;
  if (v <= M)
    o->lc = ins(o->lc, L, M, v);
  else
    o->rc = ins(o->rc, M + 1, R, v);
  return o;
}
void init() {
  nul = new Node;
  nul->cnt = 0;
  nul->lc = nul->rc = nul;
  rt[0] = nul;
  for (int i = 1; i <= n; ++i) rt[i] = ins(rt[i - 1], 1, n, a[i]);
}
int _query(Node *o, int L, int R) {
  if (L >= ql && R <= qr) {
    return o->cnt;
  } else {
    int M = (L + R) / 2, ans = 0;
    if (ql <= M) ans += _query(o->lc, L, M);
    if (qr > M) ans += _query(o->rc, M + 1, R);
    return ans;
  }
}
int query(int l, int r, int v) {
  ql = v, qr = n;
  return _query(rt[r], 1, n) - _query(rt[l - 1], 1, n);
}
}  // namespace PSGT
int main() {
  _w = scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    _w = scanf("%d", a + i);
    a[i] = min(a[i], n);
  }
  PSGT::init();
  long long ans = 0;
  for (int i = 1; i < n; ++i) {
    int L = i + 1;
    int R = a[i];
    if (L <= R) ans += PSGT::query(L, R, i);
  }
  printf("%lld\n", ans);
  return 0;
}
