#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
const long long MAXN = 1e5 + 5;
const long long LOG = 20;
long long lg[MAXN];
pair<long long, long long> t[MAXN][LOG];
long long n;
vector<long long> mas;
void build() {
  long long i, j;
  for (i = 0; i < n; i++) t[i][0] = {mas[i], i};
  lg[1] = 0;
  for (i = 2; i < n; i++) lg[i] = lg[i / 2] + 1;
  for (j = 0; j < LOG; j++)
    for (i = 0; i < n; i++) {
      if (i + (1 << (j + 1)) > n) break;
      if (t[i][j].first >= t[i + (1 << j)][j].first)
        t[i][j + 1] = t[i][j];
      else
        t[i][j + 1] = t[i + (1 << j)][j];
    }
}
pair<long long, long long> get(long long l, long long r) {
  long long j = lg[r - l + 1];
  if (t[l][j].first >= t[r - (1 << j) + 1][j].first) return t[l][j];
  return t[r - (1 << j) + 1][j];
}
signed main() {
  long long i;
  cin >> n;
  mas.resize(n);
  for (i = 0; i < n - 1; i++) {
    cin >> mas[i];
    mas[i]--;
  }
  mas[i] = n - 1;
  build();
  vector<long long> dp(n);
  dp[n - 1] = 0;
  long long val, num, sum = 0;
  for (i = n - 2; i >= 0; i--) {
    tie(val, num) = get(i + 1, mas[i]);
    dp[i] = num - i + dp[num] + n - 1 - mas[i];
    sum += dp[i];
  }
  cout << sum << '\n';
}
