#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int t[1000005];
int fa = 1;
pair<int, int> b[200005];
bool s[200005];
long long cnt = 0;
template <typename T>
void create(int node, int left, int right, T *arr) {
  if (left == right) {
    t[node] = arr[left];
    return;
  }
  int mid = left + (right - left) / 2;
  create(node * 2, left, mid, arr);
  create(node * 2 + 1, mid + 1, right, arr);
  t[node] = t[node * 2] + t[node * 2 + 1];
}
void update(int node, int left, int right, int pos, int val) {
  if (left == pos && right == pos) {
    t[node] = val;
    return;
  }
  int mid = left + (right - left) / 2;
  if (pos <= mid)
    update(node * 2, left, mid, pos, val);
  else if (pos > mid)
    update(node * 2 + 1, mid + 1, right, pos, val);
  t[node] = t[node * 2] + t[node * 2 + 1];
}
int query(int node, int left, int right, int left_q, int right_q) {
  if (left == left_q && right == right_q) return t[node];
  int mid = left + (right - left) / 2;
  if (right_q <= mid) return query(node * 2, left, mid, left_q, right_q);
  if (left_q > mid)
    return query(node * 2 + 1, mid + 1, right, left_q, right_q);
  else
    return query(node * 2, left, mid, left_q, mid) +
           query(node * 2 + 1, mid + 1, right, mid + 1, right_q);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = min(a[i], n);
    b[i] = make_pair(i, a[i]);
  }
  sort(b + 1, b + n + 1, [](pair<int, int> x, pair<int, int> y) {
    if (x.second == y.second) return x.first < y.first;
    return x.second < y.second;
  });
  for (int i = 1; i <= n; i++) s[i] = 1;
  create(1, 1, n, s);
  for (int i = 1; i <= n; i++) {
    for (; fa <= n && b[fa].second < i; fa++) {
      update(1, 1, n, b[fa].first, 0);
      s[b[fa].first] = 0;
    }
    if (a[i] <= i) continue;
    cnt += (long long)query(1, 1, n, i + 1, a[i]);
  }
  cout << cnt << '\n';
  return 0;
}
