#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], T[maxn];
int n;
void add(int x, int p) {
  for (; x <= n; x += x & -x) T[x] += p;
}
long long sum(int x) {
  long long res = 0;
  for (; x; x -= x & -x) res += T[x];
  return res;
}
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    while (!pq.empty() && pq.top().first < i) {
      add(pq.top().second, -1);
      pq.pop();
    }
    ans += sum(min(i, a[i]));
    if (a[i] <= i) continue;
    add(i, 1);
    pq.push(make_pair(a[i], i));
  }
  printf("%lld\n", ans);
  return 0;
}
