#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
int a[N];
long long int dp[N];
pair<int, int> seg[4 * N];
void build(int nd, int l, int r) {
  if (l > r) return;
  if (l == r) {
    seg[nd] = make_pair(a[l], l);
    return;
  }
  int mid = (l + r) / 2;
  build(2 * nd, l, mid);
  build(2 * nd + 1, mid + 1, r);
  seg[nd] = max(seg[2 * nd], seg[2 * nd + 1]);
}
pair<int, int> query(int nd, int l, int r, int ql, int qr) {
  if (ql > r || l > qr) return make_pair(-1, -1);
  if (ql <= l && qr >= r) return seg[nd];
  int mid = (l + r) / 2;
  pair<int, int> p1 = query(2 * nd, l, mid, ql, qr);
  pair<int, int> p2 = query(2 * nd + 1, mid + 1, r, ql, qr);
  return max(p1, p2);
}
int main() {
  int n;
  scanf("%d", &n);
  int i;
  for (i = 1; i < n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  long long ans = 0;
  dp[n] = 0;
  dp[n - 1] = 1;
  ans = dp[n - 1];
  for (i = n - 2; i >= 1; i--) {
    pair<int, int> p = query(1, 1, n, i + 1, a[i]);
    dp[i] = dp[p.second] + n - i - a[i] + p.second;
    ans = ans + dp[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
