#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 10;
int n;
int a[MAX];
long long dp[MAX] = {0};
int t[4 * MAX];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = tl;
    return;
  }
  int tm = (tl + tr) / 2;
  build(2 * v, tl, tm);
  build(2 * v + 1, tm + 1, tr);
  t[v] = a[t[2 * v]] > a[t[2 * v + 1]] ? t[2 * v] : t[2 * v + 1];
}
int query(int v, int tl, int tr, int l, int r) {
  if (r < l) return n;
  if (tl == l && tr == r) return t[v];
  int tm = (tl + tr) / 2;
  int li = query(2 * v, tl, tm, l, min(r, tm));
  int ri = query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
  int res = a[li] > a[ri] ? li : ri;
  return res;
}
void clear() {}
void solve() {
  for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) a[i]--;
  a[n] = -1;
  build(1, 0, n - 1);
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    int m = query(1, 0, n - 1, i + 1, a[i]);
    dp[i] = dp[m] + (n - i - 1) - (a[i] - m);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) res += dp[i];
  printf("%lld\n", res);
}
int main() {
  while (scanf("%d", &n) == 1) {
    clear();
    solve();
    return 0;
  }
  return 0;
}
