#include <bits/stdc++.h>
using namespace std;
long long n, q, b, s1, s2, pointer1, pointer2, arr[200069], cnt;
vector<long long> vv[400069];
void build() {
  for (long long i = n - 1; i > 0; --i) {
    s1 = vv[i << 1].size() - 1;
    s2 = vv[i << 1 | 1].size() - 1;
    pointer1 = 0, pointer2 = 0;
    while ((pointer1 <= s1) && (pointer2 <= s2)) {
      if (vv[i << 1][pointer1] > vv[i << 1 | 1][pointer2]) {
        vv[i].push_back(vv[i << 1 | 1][pointer2]);
        pointer2++;
      } else {
        vv[i].push_back(vv[i << 1][pointer1]);
        pointer1++;
      }
    }
    if (pointer1 > s1) {
      while (pointer2 <= s2) {
        vv[i].push_back(vv[i << 1 | 1][pointer2]);
        pointer2++;
      }
    } else {
      while (pointer1 <= s1) {
        vv[i].push_back(vv[i << 1][pointer1]);
        pointer1++;
      }
    }
  }
}
long long query(long long l, long long r, long long k) {
  long long res = 0;
  for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) {
      long long lo = 0, hi = vv[l].size() - 1, mid;
      while (lo < hi) {
        mid = (lo + hi) / 2;
        if (vv[l][mid] >= k) {
          hi = mid;
        } else {
          lo = mid + 1;
        }
      }
      if (vv[l][hi] >= k) {
        res += (vv[l].size() - hi);
      }
      l++;
    }
    if ((r & 1) == 0) {
      long long lo = 0, hi = vv[r].size() - 1, mid;
      while (lo < hi) {
        mid = (lo + hi) / 2;
        if (vv[r][mid] >= k) {
          hi = mid;
        } else {
          lo = mid + 1;
        }
      }
      if (vv[r][hi] >= k) {
        res += (vv[r].size() - hi);
      }
      r--;
    }
  }
  return res;
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> b;
    arr[i + 1] = b;
    vv[i + n].push_back(b);
  }
  build();
  for (long long i = 1; i < n; i++) {
    cnt += query(i, min(n - 1, arr[i] - 1), i);
  }
  cout << cnt;
  return 0;
}
