#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;
pair<int, int> ST[N << 2];
long long dp[N], all;
int n, a[N];
pair<int, int> init(int k, int bas, int son) {
  if (bas == son) return ST[k] = make_pair(a[bas], bas);
  return ST[k] = max(init((k + k), bas, (bas + son >> 1)),
                     init((k + k + 1), (bas + son >> 1) + 1, son));
}
pair<int, int> query(int k, int bas, int son, int x, int y) {
  if (bas > y || son < x) return make_pair(0, 0);
  if (x <= bas && son <= y) return ST[k];
  return max(query((k + k), bas, (bas + son >> 1), x, y),
             query((k + k + 1), (bas + son >> 1) + 1, son, x, y));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d", &a[i]);
  }
  a[n] = n;
  init(1, 1, n);
  dp[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    int t = query(1, 1, n, i + 1, a[i]).second;
    dp[i] = dp[t] + (n - a[i]) + (t - i);
    all += dp[i];
  }
  cout << all << '\n';
  return 0;
}
