#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, a[N], dist[N];
long long ans, dp[N];
pair<int, int> T[N * 4];
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) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm + 1, tr);
  T[v] = max(T[v * 2], T[v * 2 + 1]);
}
pair<int, int> get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(0, 0);
  if (l <= tl && tr <= r) return T[v];
  int tm = (tl + tr) / 2;
  return max(get(l, r, v * 2, tl, tm), get(l, r, v * 2 + 1, tm + 1, tr));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  build();
  for (int i = n - 1; i; i--) {
    pair<int, int> nw = get(i + 1, a[i]);
    dp[i] = dp[nw.second] + (n - i);
    if (i < n - 1) dp[i] -= (a[i] - nw.second);
    ans += dp[i];
  }
  cout << ans;
  return 0;
}
