#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int ret = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  do {
    ret = ret * 10 + c - '0';
    c = getchar();
  } while ('0' <= c && c <= '9');
  return ret;
}
int n;
int a[100100];
int mmax[100100 << 4], name[100100 << 4];
void build(int id, int l, int r) {
  if (l == r) {
    mmax[id] = a[l];
    name[id] = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  name[id] =
      (mmax[id << 1] > mmax[id << 1 | 1] ? name[id << 1] : name[id << 1 | 1]);
  mmax[id] = max(mmax[id << 1], mmax[id << 1 | 1]);
}
int ql, qr, qval, qid;
void query(int id, int l, int r) {
  if (ql <= l && r <= qr) {
    qval < mmax[id] ? (qval = mmax[id], qid = name[id]) : 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) query(id << 1, l, mid);
  if (mid < qr) query(id << 1 | 1, mid + 1, r);
}
long long f[100100], ans;
int main() {
  n = read();
  for (int i = 1; i < n; i++) a[i] = read();
  build(1, 1, n);
  ans = f[n - 1] = 1;
  for (int i = n - 2; i >= 1; i--) {
    ql = i + 1, qr = a[i], qval = 0, qid = 0;
    query(1, 1, n);
    f[i] = f[qid] + (n - i) - (a[i] - qid);
    ans += f[i];
  }
  printf("%lld\n", ans);
  return 0;
}
