#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
inline void print(long long x) {
  if (x < 0) {
    putchar('-');
    print(abs(x));
    return;
  }
  if (x <= 9)
    putchar(x + '0');
  else {
    print(x / 10);
    putchar(x % 10 + '0');
  }
}
inline long long qpow(long long x, long long e, long long _MOD) {
  long long ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % _MOD;
    x = x * x % _MOD;
    e >>= 1;
  }
  return ans;
}
long long n = read(), a[200005];
struct Fenwick_Tree {
  long long bit[200005];
  inline long long lowbit(long long x) { return x & (-x); }
  inline void add(long long x, long long val) {
    x++;
    for (long long i = x; i <= 200002; i += lowbit(i)) bit[i] += val;
  }
  inline long long query(long long x) {
    x++;
    long long ans = 0;
    for (long long i = x; i; i -= lowbit(i)) ans += bit[i];
    return ans;
  }
} tr;
struct query {
  long long x, y;
  friend bool operator<(query a, query b) { return a.x < b.x; }
} q[200005];
signed main() {
  for (long long i = 1; i <= n; i++) a[i] = read(), a[i] = min(a[i], n);
  for (long long i = 1; i <= n; i++) {
    q[i].x = min(a[i], i - 1);
    q[i].y = i;
  }
  sort(q + 1, q + n + 1);
  long long ans = 0;
  long long t = 1;
  for (long long i = 1; i <= n; i++) {
    while (t <= q[i].x) tr.add(a[t], 1), t++;
    ans += (tr.query(200001) - tr.query(q[i].y - 1));
  }
  cout << ans << endl;
  return 0;
}
