#include <bits/stdc++.h>
using namespace std;
long long arr[200022];
long long b[200022];
vector<vector<long long> > vect(4 * 200022);
void merge(long long i, long long a, long long j, long long b1, long long pos) {
  long long s = i;
  long long e = b1;
  while (i <= a && j <= b1) {
    if (b[i] < b[j]) {
      vect[pos].push_back(b[i++]);
    } else
      vect[pos].push_back(b[j++]);
  }
  while (i <= a) vect[pos].push_back(b[i++]);
  while (j <= b1) vect[pos].push_back(b[j++]);
  long long k = 0;
  for (; s <= e; s++) b[s] = vect[pos][k++];
  return;
}
void mergesort(long long i, long long j, long long pos) {
  if (i < j) {
    long long mid = i + j;
    mid /= 2;
    mergesort(i, mid, pos * 2 + 1);
    mergesort(mid + 1, j, pos * 2 + 2);
    merge(i, mid, mid + 1, j, pos);
  } else if (i == j) {
    vect[pos].push_back(b[i]);
  }
}
long long query(long long s, long long e, long long st, long long ed,
                long long pos, long long ele) {
  if (s > ed || e < st)
    return 0;
  else if (s <= st && e >= ed) {
    return vect[pos].end() -
           lower_bound((vect[pos]).begin(), (vect[pos]).end(), ele);
  } else {
    return query(s, e, st, (st + ed) / 2, pos * 2 + 1, ele) +
           query(s, e, ((st + ed) / 2) + 1, ed, pos * 2 + 2, ele);
  }
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] = min(arr[i], n);
    b[i] = arr[i];
  }
  mergesort(0, n - 1, 0);
  long long ans = 0;
  for (long long i = n; i >= 1; i--) {
    long long end = min(i, arr[i - 1]);
    if (end == i) end--;
    ans += query(0, end - 1, 0, n - 1, 0, i);
  }
  cout << ans << '\n';
}
