#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
const int maxlog = (int)20;
const int P = mod;
int n, a[maxn];
long long ans, dp[maxn];
pair<int, int> t[4 * maxn];
void build(int v = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    t[v] = make_pair(a[tl], tl);
    return;
  }
  int tm = (tl + tr) >> 1;
  build(v + v, tl, tm);
  build(v + v + 1, tm + 1, tr);
  t[v] = max(t[v + v], t[v + v + 1]);
}
pair<int, int> get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (l > r || r < tl || l > tr) return make_pair(0, 0);
  if (l <= tl && tr <= r) return t[v];
  int tm = (tl + tr) >> 1;
  return max(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  build();
  for (int i = n - 1; i >= 1; i--) {
    int m = get(i + 1, a[i]).second;
    dp[i] = n - i + dp[m] - (a[i] - m);
    ans += dp[i];
  }
  cout << ans;
}
