#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, L = 17;
long long n, a[N], dp[N], ans;
pair<int, int> mx[N][L];
int get(int l, int r) {
  pair<int, int> res = {0, 0};
  for (int i = L - 1; ~i; i--)
    if (1 << i <= r - l) {
      res = max(res, mx[l][i]);
      l += 1 << i;
    }
  return res.second;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    mx[i][0] = {a[i], i};
  }
  mx[n - 1][0] = {n - 1, n - 1};
  for (int j = 1; j < L; j++)
    for (int i = 0; i < n; i++)
      mx[i][j] = max(mx[i][j - 1], mx[min(i + (1ll << j - 1), n)][j - 1]);
  for (int i = n - 2; ~i; i--) {
    int x = get(i + 1, a[i]);
    ans += (dp[i] = dp[x] + n - a[i] + x - i);
  }
  cout << ans << endl;
}
