#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long f[N], ans;
int n, a[N];
pair<int, int> T[N * 4];
void build(int x, int l, int r) {
  if (l == r)
    T[x] = make_pair(a[l], l);
  else {
    int mid = (l + r) >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    T[x] = max(T[x << 1], T[x << 1 | 1]);
  }
}
pair<int, int> get(int x, int l, int r, int s, int t) {
  if (t < l || s > r) return make_pair(0, 0);
  if (s <= l && t >= r) return T[x];
  int mid = (l + r) >> 1;
  return max(get(x << 1, l, mid, s, t), get(x << 1 | 1, mid + 1, r, s, t));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &a[i]);
  build(1, 1, n - 1);
  f[n - 1] = 1;
  ans = 1;
  for (int i = n - 2; i >= 1; i--) {
    int j = get(1, 1, n - 1, i, a[i]).second;
    f[i] = f[j] - (a[i] - j) + n - i;
    ans += f[i];
  }
  printf("%I64d", ans);
  return 0;
}
