#include <bits/stdc++.h>
using namespace std;
uint64_t ans[100001];
int spt[17][100001], inp[100001];
int n, a;
void add_val(int ind) {
  spt[0][ind] = ind;
  int pw = 1;
  while (ind + (1 << pw) - 1 <= n) {
    int ind1 = spt[pw - 1][ind];
    int ind2 = spt[pw - 1][ind + (1 << (pw - 1))];
    spt[pw][ind] = inp[ind1] > inp[ind2] ? ind1 : ind2;
    pw++;
  }
}
int query(int l, int r) {
  int diff = r - l + 1;
  int len = 31 - __builtin_clz(diff);
  int ind1 = spt[len][l];
  int ind2 = spt[len][r - (1 << len) + 1];
  return inp[ind1] > inp[ind2] ? ind1 : ind2;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &inp[i]);
  add_val(n);
  inp[n] = n;
  for (int i = n - 1; i > 0; i--) {
    int ind = query(i + 1, inp[i]);
    add_val(i);
    ans[i] = n - inp[i] + ans[ind] + ind - i;
  }
  uint64_t sma = 0;
  for (int i = 1; i < n; i++) sma += ans[i];
  printf("%llu\n", sma);
}
