#include <bits/stdc++.h>
using namespace std;
const double PI = acos(0) * 2;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
const int oo = 1e9;
const double foo = 1e30;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
const int MAXN = 100003;
const int LOGMAXN = 18;
int a[MAXN], n, M[MAXN][LOGMAXN];
long long ans = 0, dp[MAXN];
void process2(int M[MAXN][LOGMAXN], int A[MAXN], int N) {
  int i, j;
  for (i = 0; i <= N; i++) M[i][0] = i;
  for (j = 1; 1 << j <= N; j++)
    for (i = 0; i + (1 << j) - 1 < N; i++)
      if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
        M[i][j] = M[i][j - 1];
      else
        M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
int main() {
  cin >> n;
  n--;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) M[i][0] = i;
  for (int k = 1; (1 << k) <= n; k++)
    for (int i = 1; i + (1 << k) - 1 <= n; i++)
      if (a[M[i][k - 1]] < a[M[i + (1 << (k - 1))][k - 1]])
        M[i][k] = M[i + (1 << (k - 1))][k - 1];
      else
        M[i][k] = M[i][k - 1];
  dp[n + 1] = 0;
  dp[n] = 1;
  ans = 1;
  int u, v, k, t;
  for (int i = n - 1; i >= 1; i--) {
    u = i + 1;
    v = a[i];
    if (v == n + 1) {
      dp[i] = n - i + 1;
      ans += dp[i];
      continue;
    }
    k = log2(v - u + 1);
    if (a[M[u][k]] < a[M[v - (1 << k) + 1][k]]) {
      t = M[v - (1 << k) + 1][k];
    } else
      t = M[u][k];
    dp[i] = dp[t] + (long long)(n + 1 - t + 1) - (long long)(a[i] - t) +
            (long long)(t - i - 1);
    ans += dp[i];
  }
  cout << ans;
}
