#include <bits/stdc++.h>
using namespace std;
char gc() { return getchar(); }
template <typename T>
int read(T &ans) {
  ans = 0;
  T f = 1;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == EOF) return EOF;
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}
template <typename T1, typename T2>
int read(T1 &a, T2 &b) {
  return read(a) != EOF && read(b) != EOF ? 2 : EOF;
}
template <typename T1, typename T2, typename T3>
int read(T1 &a, T2 &b, T3 &c) {
  return read(a, b) != EOF && read(c) != EOF ? 3 : EOF;
}
const int Maxn = 210000;
const long long inf = 100000000000000ll;
int tl[Maxn << 2], tr[Maxn << 2], tn[Maxn << 2], a[Maxn], n;
long long ans;
vector<int> v[Maxn];
void build(int root, int l, int r) {
  tl[root] = l, tr[root] = r;
  if (l == r) return;
  int mid = l + r >> 1;
  build(root << 1, l, mid);
  build((root << 1) | 1, mid + 1, r);
}
void add(int root, int x) {
  int l = tl[root], r = tr[root], mid = l + r >> 1;
  tn[root]++;
  if (l == r) return;
  if (x <= mid)
    add(root << 1, x);
  else
    add((root << 1) | 1, x);
}
int query(int root, int ql, int qr) {
  int l = tl[root], r = tr[root], mid = l + r >> 1;
  if (ql <= l && qr >= r) return tn[root];
  int ans = 0;
  if (ql <= mid) ans += query(root << 1, ql, qr);
  if (qr > mid) ans += query((root << 1) | 1, ql, qr);
  return ans;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    a[i] = min(a[i], n);
    v[min(a[i], i - 1)].push_back(i);
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    add(1, a[i]);
    for (auto j : v[i]) ans += query(1, j, n);
  }
  cout << ans << endl;
  return 0;
}
