#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, i, j, a[N], c[N];
long long ans;
vector<int> v[N];
int sum(int k) {
  int cnt = 0;
  for (int l = k; l; l -= l & -l) cnt += c[l];
  return cnt;
}
void add(int x, int y) {
  for (int l = x; l <= n; l += l & -l) c[l] += y;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] = min(a[i], n);
  for (i = 1; i <= n; i++) {
    ans += sum(a[i]);
    if (a[i] > i) {
      add(i, 1);
      v[a[i]].push_back(i);
    }
    for (j = v[i].size() - 1; j >= 0; j--) add(v[i][j], -1);
  }
  printf("%lld\n", ans);
  return 0;
}
