#include <bits/stdc++.h>
using namespace std;
long long int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans % md;
}
const long long int MAXN = 2e5 + 10;
const long long int INF = 8e18;
const long long int MOD = 1e9 + 7;
vector<long long int> seg[MAXN << 2];
long long int A[MAXN], n, ans = 0;
void build(long long int id = 1, long long int l = 0, long long int r = MAXN) {
  if (r - l == 1) {
    seg[id].push_back(A[l]);
    return;
  }
  long long int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid, r);
  merge((seg[id << 1]).begin(), (seg[id << 1]).end(),
        (seg[id << 1 | 1]).begin(), (seg[id << 1 | 1]).end(),
        back_inserter(seg[id]));
}
long long int get(long long int ql, long long int qr, long long int val,
                  long long int id = 1, long long int l = 0,
                  long long int r = MAXN) {
  if (qr <= l || r <= ql) return 0;
  if (ql <= l && r <= qr) {
    return seg[id].end() - lower_bound((seg[id]).begin(), (seg[id]).end(), val);
  }
  long long int mid = (l + r) >> 1;
  return get(ql, qr, val, id << 1, l, mid) +
         get(ql, qr, val, id << 1 | 1, mid, r);
}
int main() {
  scanf("%lld", &n);
  for (long long int i = 1; i <= n; i++) {
    scanf("%lld", &A[i]);
  }
  build();
  for (long long int i = 1; i <= n; i++) {
    ans += get(1, min(i, A[i] + 1), i);
  }
  printf("%lld\n", ans);
  return 0;
}
