#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int LOGN = 20;
int n, sp[N][LOGN], a[N];
long long dp[N];
long long res = 0;
int get(int l, int r) {
  int sz = floor(log((double)(r - l + 1)) / log(2.0));
  return a[sp[l][sz]] > a[sp[r - (1 << sz) + 1][sz]]
             ? sp[l][sz]
             : sp[r - (1 << sz) + 1][sz];
}
int main() {
  scanf("%d", &n);
  a[n] = n;
  sp[n][0] = n;
  for (int i = 1; i < n; ++i) {
    scanf("%d", &a[i]);
    sp[i][0] = i;
  }
  for (int k = 1; k < LOGN; k++) {
    for (int idx = 1; idx + (1 << k) - 1 <= n; idx++) {
      if (a[sp[idx][k - 1]] > a[sp[idx + (1 << (k - 1))][k - 1]]) {
        sp[idx][k] = sp[idx][k - 1];
      } else {
        sp[idx][k] = sp[idx + (1 << (k - 1))][k - 1];
      }
    }
  }
  dp[n] = 0;
  for (int i = n - 1; i >= 1; --i) {
    int m = get(i + 1, a[i]);
    dp[i] = (long long)(m - i) + (n - a[i]) + (long long)dp[m];
    res += dp[i];
  }
  printf("%lld\n", res);
  return 0;
}
