#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
struct Seg_ {
  long long mx, pl;
} t[N << 2];
long long n, ans, a[N], f[N];
void update(long long p) {
  if (t[p << 1].mx > t[p << 1 | 1].mx) {
    t[p].pl = t[p << 1].pl;
  } else {
    t[p].pl = t[p << 1 | 1].pl;
  }
  t[p].mx = max(t[p << 1].mx, t[p << 1 | 1].mx);
}
void Build(long long p, long long l, long long r) {
  if (l == r) {
    t[p].mx = a[l];
    t[p].pl = l;
    return;
  }
  long long mid = l + r >> 1;
  Build(p << 1, l, mid);
  Build(p << 1 | 1, mid + 1, r);
  update(p);
}
Seg_ query(long long p, long long l, long long r, long long ql, long long qr) {
  if (ql > qr) {
    return {0, 0};
  }
  if (l >= ql && r <= qr) {
    return t[p];
  }
  long long mid = l + r >> 1;
  Seg_ y, res;
  y = res = {0, 0};
  if (mid >= ql) {
    res = query(p << 1, l, mid, ql, qr);
  }
  if (mid < qr) {
    y = query(p << 1 | 1, mid + 1, r, ql, qr);
  }
  if (y.mx >= res.mx) {
    res = y;
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    cin >> a[i];
  }
  a[n] = n;
  Build(1, 1, n);
  for (long long i = n - 1; i >= 1; i--) {
    long long k = query(1, 1, n, i + 1, a[i]).pl;
    f[i] = n - i;
    if (a[i] < n) {
      f[i] += f[k] - (a[i] - k);
    }
    ans += f[i];
  }
  cout << ans << endl;
  return 0;
}
