#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 100500;
long long dp[N];
int n, a[N];
pair<int, int> t[N << 2];
void build(int v, int l, int r) {
  if (l == r) {
    t[v] = {a[r], r};
    return;
  }
  int mid = (l + r) >> 1;
  build(v << 1, l, mid);
  build(v << 1 | 1, mid + 1, r);
  t[v] = max(t[v << 1], t[v << 1 | 1]);
}
pair<int, int> get(int v, int l, int r, int lx, int rx) {
  if (rx < l || r < lx) return {-1, -1};
  if (lx <= l && r <= rx) return t[v];
  int mid = (l + r) >> 1;
  return max(get(v << 1, l, mid, lx, rx), get(v << 1 | 1, mid + 1, r, lx, rx));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  dp[n - 1] = 1;
  for (int i = n - 2; i >= 1; i--) {
    pair<int, int> p = get(1, 1, n, i + 1, a[i]);
    int j = p.second;
    dp[i] = dp[j] + j - i + n - a[i];
  }
  for (int i = n - 1; i >= 1; i--) dp[i] += dp[i + 1];
  printf("%I64d", dp[1]);
  return 0;
}
