#include <bits/stdc++.h>
using namespace std;
int ft[200003];
int n;
int RSQ(int x) {
  int res = 0;
  while (x) {
    res += ft[x];
    x -= x & (-x);
  }
  return res;
}
void update(int x, int val) {
  while (x <= n) {
    ft[x] += val;
    x += x & (-x);
  }
}
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  scanf("%d", &n);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    x = min(x, n);
    while (pq.size() && pq.top().first < i) {
      update(pq.top().second, -1);
      pq.pop();
    }
    res += 1LL * RSQ(x);
    pq.push({x, i});
    update(i, 1);
  }
  printf("%lld\n", res);
}
