#include <bits/stdc++.h>
using namespace std;
inline void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long maxn = 2e5 + 123;
const long long inf = 1e9 + 123;
const long long linf = 1e18 + 123;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1);
int dx[8] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[8] = {1, 0, 0, -1, 1, 1, -1, -1};
long long a[maxn], s[maxn];
pair<long long, long long> mx[maxn][25];
long long get(int l, int r) {
  int dist = r - l + 1, cntr = 0;
  while (dist > 1) {
    dist /= 2;
    cntr++;
  }
  pair<long long, long long> mxx =
      max(mx[l][cntr], mx[r - (1 << cntr) + 1][cntr]);
  return mxx.second;
}
int main() {
  boost();
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    mx[i][0] = {a[i], i};
  }
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j + (1 << i) <= n; j++) {
      mx[j][i] = max(mx[j][i - 1], mx[j + (1 << (i - 1))][i - 1]);
    }
  }
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i] == n) {
      s[i] = n - i;
    } else {
      int j = get(i + 1, a[i]);
      s[i] = s[j] + (n - i) - (a[i] - j);
    }
    ans += s[i];
  }
  cout << ans;
  exit(0);
}
