#include <bits/stdc++.h>
using namespace std;
long long rd() {
  char c = getchar();
  long long s = 0, f = 1;
  while (c > '9' || c < '0') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
  return s * f;
}
const long long N = 100005;
long long dp[N], n, f[N][20], g[N][20], ans;
long long find(long long l, long long r) {
  long long x = log2(r - l + 1);
  if (f[l][x] > f[r - (1 << x) + 1][x])
    return g[l][x];
  else
    return g[r - (1 << x) + 1][x];
}
signed main() {
  n = rd();
  for (long long i = 1; i < n; i++) f[i][0] = rd(), g[i][0] = i;
  for (long long i = 1; i < 20; i++)
    for (long long j = 1, x = n - (1 << i) + 1; j <= x; j++) {
      if (f[j][i - 1] > f[j + (1 << i - 1)][i - 1])
        f[j][i] = f[j][i - 1], g[j][i] = g[j][i - 1];
      else
        f[j][i] = f[j + (1 << i - 1)][i - 1],
        g[j][i] = g[j + (1 << i - 1)][i - 1];
    }
  for (long long i = n - 1; i >= 1; i--) {
    long long x = find(i + 1, f[i][0]);
    if (f[i][0] >= n)
      dp[i] = n - i;
    else
      dp[i] = dp[x] - f[i][0] + x + n - i;
    ans += dp[i];
  }
  printf("%lld\n", ans);
  return 0;
}
