#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
long long t[4 * MAX_N];
long long y[MAX_N];
pair<long long, long long> mas[MAX_N];
void insert(int v, int l, int r, int i, long long a) {
  if (l == r) {
    t[v] += a;
    return;
  }
  int mid = (l + r) / 2;
  if (i <= mid)
    insert(2 * v, l, mid, i, a);
  else
    insert(2 * v + 1, mid + 1, r, i, a);
  t[v] = t[2 * v] + t[2 * v + 1];
}
long long answer(int v, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (l == L && r == R) return t[v];
  int mid = (l + r) / 2;
  long long sum = 0;
  if (L <= mid) sum += answer(2 * v, l, mid, L, min(mid, R));
  if (R > mid) sum += answer(2 * v + 1, mid + 1, r, max(mid + 1, L), R);
  return sum;
}
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> y[i];
    y[i]--;
    if (y[i] > n) y[i] = n;
    mas[i] = make_pair(y[i], i);
    if (y[i] >= i) ans--;
  }
  sort(mas, mas + n);
  int v = 0;
  for (int i = 0; i < n; i++) {
    insert(1, 0, MAX_N - 1, y[i], 1);
    while (v < n) {
      if (mas[v].first != i) break;
      ans += answer(1, 0, MAX_N - 1, mas[v].second, MAX_N - 1);
      v++;
    }
  }
  while (v < n) {
    ans += answer(1, 0, MAX_N - 1, mas[v].second, MAX_N - 1);
    v++;
  }
  cout << ans / 2LL;
  return 0;
}
