#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 25;
int n, a[N];
long long dp[N];
struct node {
  int l, r, ans;
} tr[4 * N];
void pushup(int o) {
  if (a[tr[2 * o].ans] > a[tr[2 * o + 1].ans])
    tr[o].ans = tr[2 * o].ans;
  else
    tr[o].ans = tr[2 * o + 1].ans;
}
void build(int o, int L, int R) {
  tr[o].l = L;
  tr[o].r = R;
  if (L == R) {
    tr[o].ans = L;
    return;
  }
  int mid = (L + R) >> 1;
  build(2 * o, L, mid);
  build(2 * o + 1, mid + 1, R);
  pushup(o);
}
int query(int o, int L, int R) {
  if (L <= tr[o].l && R >= tr[o].r) return tr[o].ans;
  int mid = (tr[o].l + tr[o].r) >> 1;
  if (R <= mid)
    return query(2 * o, L, R);
  else if (L > mid)
    return query(2 * o + 1, L, R);
  else {
    int fl = query(2 * o, L, mid), fr = query(2 * o + 1, mid + 1, R);
    if (a[fl] > a[fr])
      return fl;
    else
      return fr;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) scanf("%d", &a[i]);
  a[n] = n;
  build(1, 1, n);
  long long ans = 0;
  dp[n] = 0;
  for (int i = n - 1; i > 0; i--) {
    int temp = query(1, i + 1, a[i]);
    dp[i] = dp[temp] + (long long)(n - i - (a[i] - temp));
    ans += dp[i];
  }
  cout << ans << "\n";
  return 0;
}
