#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const long double eps = 1e-12;
int n, a[N], seg[4 * N];
long long dp[N];
void build(int l = 0, int r = n, int idx = 1) {
  if (r - l == 1) {
    seg[idx] = l;
    return;
  }
  int m = (l + r) / 2;
  build(l, m, idx * 2 + 0);
  build(m, r, idx * 2 + 1);
  if (a[seg[idx * 2 + 0]] > a[seg[idx * 2 + 1]])
    seg[idx] = seg[idx * 2 + 0];
  else
    seg[idx] = seg[idx * 2 + 1];
}
int get(int ql, int qr, int l = 0, int r = n, int idx = 1) {
  if (qr <= l || r <= ql) return N - 1;
  if (ql <= l && r <= qr) return seg[idx];
  int m = (l + r) / 2;
  int a1 = get(ql, qr, l, m, idx * 2 + 0);
  int a2 = get(ql, qr, m, r, idx * 2 + 1);
  if (a[a1] > a[a2]) return a1;
  return a2;
}
int main() {
  a[N - 1] = -1;
  n = in();
  for (int i = 0; i < n - 1; i++) a[i] = in(), a[i]--;
  build();
  long long ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    int ind = get(i + 1, a[i] + 1);
    dp[i] = dp[ind] + n - 1 - i - a[i] + ind;
    ans += dp[i];
  }
  cout << ans;
  return 0;
}
