#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c<'0' | c> '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const long long N = 200005;
long long ara[N];
vector<long long> v[N * 4];
void build(long long node, long long l, long long r) {
  if (l == r) {
    v[node].emplace_back(ara[l]);
    return;
  }
  long long mid = (l + r) >> 1;
  build(node * 2, l, mid);
  build(node * 2 + 1, mid + 1, r);
  merge(v[node * 2].begin(), v[node * 2].end(), v[node * 2 + 1].begin(),
        v[node * 2 + 1].end(), back_inserter(v[node]));
}
long long query(long long node, long long l, long long r, long long x,
                long long y, long long val) {
  if (l >= x && r <= y) {
    return v[node].size() -
           (lower_bound(v[node].begin(), v[node].end(), val) - v[node].begin());
  }
  if (l > y || r < x) return 0;
  long long mid = (l + r) >> 1;
  return query(node * 2, l, mid, x, y, val) +
         query(node * 2 + 1, mid + 1, r, x, y, val);
}
int main() {
  long long n = ({
    long long a;
    read(a);
    a;
  });
  for (int i = 1; i <= n; i++)
    ara[i] = ({
      long long a;
      read(a);
      a;
    });
  build(1, 1, n);
  long long s = 0;
  for (long long i = 1; i < n; ++i) {
    if (ara[i] <= i) continue;
    if (ara[i] > n) ara[i] = n;
    s += query(1, 1, n, i + 1, ara[i], i);
  }
  printf("%lld", s), printf("\n");
}
