#include <bits/stdc++.h>
using namespace std;
int n, m;
struct seasons {
  int season;
  int episode;
} b[200010];
int a[200010];
struct treenode {
  int l, r;
  int sum;
  int lc, rc;
} tree[400010] = {0};
int lt = 1;
void quicksort(int h, int e) {
  int i = h, j = e;
  struct seasons val;
  val = b[(h + e) / 2];
  b[(h + e) / 2] = b[h];
  do {
    while (i < j && (val.episode < b[j].episode)) j--;
    if (i < j) b[i++] = b[j];
    while (i < j && (val.episode > b[i].episode)) i++;
    if (i < j) b[j--] = b[i];
  } while (i < j);
  b[i] = val;
  if (i - 1 > h) quicksort(h, i - 1);
  if (i + 1 < e) quicksort(i + 1, e);
}
void Insert_node(int node, int k) {
  int mid;
  tree[node].sum++;
  if (tree[node].l < tree[node].r) {
    mid = (tree[node].l + tree[node].r) / 2;
    if (k <= mid) {
      if (!tree[node].lc) {
        tree[node].lc = ++lt;
        tree[lt].l = tree[node].l;
        tree[lt].r = mid;
        tree[lt].lc = tree[lt].rc = 0;
        tree[lt].sum = 0;
      }
      Insert_node(tree[node].lc, k);
    } else {
      if (!tree[node].rc) {
        tree[node].rc = ++lt;
        tree[lt].l = mid + 1;
        tree[lt].r = tree[node].r;
        tree[lt].lc = tree[lt].rc = 0;
        tree[lt].sum = 0;
      }
      Insert_node(tree[node].rc, k);
    }
  }
}
int findsum(int node, int h, int e) {
  int mid, ans = 0;
  if (!node || !tree[node].sum) return 0;
  if (tree[node].l == h && tree[node].r == e) return tree[node].sum;
  mid = (tree[node].l + tree[node].r) / 2;
  if (e <= mid) return (findsum(tree[node].lc, h, e));
  if (h > mid) return (findsum(tree[node].rc, h, e));
  return findsum(tree[node].lc, h, mid) + findsum(tree[node].rc, mid + 1, e);
}
void Initialize() {
  int i, j, k;
  scanf("%d", &n);
  b[0].season = b[0].episode = a[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > n) a[i] = n;
    b[i].season = i;
    b[i].episode = a[i];
  }
  quicksort(1, n);
  tree[1].l = 1;
  tree[1].r = n;
  tree[1].lc = tree[1].rc = 0;
}
int main() {
  Initialize();
  int i, j, k;
  long long ans = 0;
  j = 1;
  for (i = 1; i < n; i++)
    if (a[i] > i) {
      while (j <= n && (b[j].episode < i || b[j].season <= i)) {
        if (b[j].season > i) {
          Insert_node(1, b[j].season);
        }
        j++;
      }
      ans += a[i] - i - findsum(1, i + 1, a[i]);
    }
  printf("%I64d", ans);
  return 0;
}
