#include <bits/stdc++.h>
using namespace std;
const long long N = 100010;
long long n, ans, a[N], st[N][20], f[N];
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
inline long long Max(long long x, long long y) { return a[x] > a[y] ? x : y; }
inline void init() {
  for (long long j = 1; j <= 20; j++)
    for (long long i = 1; i + (1 << j) - 1 <= n; i++)
      st[i][j] = Max(st[i][j - 1], st[i + (1 << j - 1)][j - 1]);
}
inline long long ask(long long l, long long r) {
  long long k = log2(r - l + 1);
  return Max(st[l][k], st[r - (1 << k) + 1][k]);
}
signed main() {
  n = read();
  for (long long i = 1; i < n; i++) {
    a[i] = read();
    st[i][0] = i;
  }
  init();
  for (long long i = n - 1; i >= 1; i--) {
    long long k = ask(i + 1, a[i]);
    if (a[i] >= n)
      f[i] = n - i;
    else
      f[i] = f[k] + (n - i) - (a[i] - k);
    ans += f[i];
  }
  printf("%lld\n", ans);
  return 0;
}
