#include <bits/stdc++.h>
using namespace std;
long long int add(long long int x, long long int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
long long int mul(long long int x, long long int y) {
  return ((x % 1000000007) * (y % 1000000007)) % 1000000007;
}
long long int sub(long long int x, long long int y) {
  return (x - y + 1000000007) % 1000000007;
}
void solve() {
  long long int n, i, j, q, l, r, ans = 0;
  cin >> n;
  long long int a[n], log[n + 1], po[n + 1];
  log[1] = 0;
  log[2] = 1;
  po[0] = 1;
  for (long long int i = 3; i < n + 1; i++) {
    log[i] = 1 + log[i / 2];
  }
  long long int k = log[n], dp[n];
  dp[n - 1] = 0;
  dp[n - 2] = 1;
  pair<long long int, long long int> sp[n + 1][k + 1];
  for (long long int i = 1; i < k + 1; i++) {
    po[i] = po[i - 1] * 2;
  }
  for (long long int i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  a[n - 1] = n - 1;
  for (long long int i = 0; i < n; i++) {
    sp[i][0] = {a[i], i};
  }
  for (long long int j = 1; j < k + 1; j++) {
    for (i = 0; i + (1 << (j - 1)) < n; i++) {
      sp[i][j] = max(sp[i][j - 1], sp[i + (1 << (j - 1))][j - 1]);
    }
  }
  for (i = n - 3; i >= 0; i--) {
    long long int b = log[a[i] - i];
    pair<long long int, long long int> c =
        max(sp[i + 1][b], sp[1 + a[i] - (1 << b)][b]);
    dp[i] = dp[c.second] + (n - 1 - i) - (a[i] - c.second);
  }
  for (long long int i = 0; i < n; i++) {
    ans += dp[i];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
