#include <bits/stdc++.h>
using namespace std;
long long int n, a[200009], low[800009], high[800009], kq = 0;
vector<long long int> p[800009];
void Inp() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = min(a[i], n);
    if (a[i] >= i) {
      kq--;
    }
  }
}
void Mix(long long int v) {
  long long int k = p[v * 2].size(), l = p[v * 2 + 1].size(), b1 = 0, b2 = 0;
  while (b1 < k || b2 < l) {
    if (b1 == k) {
      p[v].push_back(p[v * 2 + 1][b2]);
      b2++;
      continue;
    }
    if (b2 == l) {
      p[v].push_back(p[v * 2][b1]);
      b1++;
      continue;
    }
    if (p[v * 2][b1] > p[v * 2 + 1][b2]) {
      p[v].push_back(p[v * 2 + 1][b2]);
      b2++;
      continue;
    } else {
      p[v].push_back(p[v * 2][b1]);
      b1++;
      continue;
    }
  }
}
void Built(long long int v, long long int l, long long int h) {
  low[v] = l;
  high[v] = h;
  if (l == h) {
    p[v].push_back(a[l]);
  } else {
    long long int m = (l + h) / 2;
    Built(v * 2, l, m);
    Built(v * 2 + 1, m + 1, h);
    Mix(v);
  }
}
long long int Count(long long int v, long long int l, long long int h,
                    long long int k) {
  if (low[v] > h || high[v] < l) {
    return 0;
  }
  if (low[v] >= l && high[v] <= h) {
    return (high[v] - low[v] + 1 -
            (lower_bound(p[v].begin(), p[v].end(), k) - p[v].begin()));
  }
  return Count(v * 2, l, h, k) + Count(v * 2 + 1, l, h, k);
}
void Solve() {
  for (int i = 1; i <= n; i++) {
    kq += Count(1, 1, a[i], i);
  }
  cout << kq / 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Inp();
  Built(1, 1, n);
  Solve();
}
