#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sign = 1;
  int x = 0;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') sign = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * sign;
}
inline void write(long long k) {
  if (k < 0) putchar('-'), k *= -1;
  char ch[20];
  int num = 0;
  while (k) ch[++num] = k % 10, k /= 10;
  if (num == 0) ch[++num] = 0;
  while (num) putchar(ch[num--] + '0');
}
const int N = 1e5;
pair<int, int> st[N][17];
int n;
long long dp[N], ans;
int main() {
  n = read();
  for (register int i = (0); i < (n - 1); i++) st[i][0] = {read() - 1, i};
  st[n - 1][0] = {n - 1, n - 1};
  for (int i = 1, t = 1; i < 17; i++, t <<= 1)
    for (int j = 0; j + t * 2 <= n; j++)
      st[j][i] = max(st[j][i - 1], st[j + t][i - 1]);
  for (int i = n - 2; i >= 0; i--) {
    int r = st[i][0].first - i;
    int j = i + 1, k = 0, l = 1;
    pair<int, int> m = {0, 0};
    while (r) {
      if (r & 1) m = max(m, st[j][k]), j += l;
      k++, l <<= 1, r >>= 1;
    }
    dp[i] = dp[m.second] - (st[i][0].first - m.second) + n - i - 1;
    ans += dp[i];
  }
  write(ans);
  return 0;
}
