#include <bits/stdc++.h>
using std::max;
const int N = 100005;
int a[N], n;
long long Ans[N], sum;
struct note {
  int x, id;
  bool operator>(const note x) const { return this->x > x.x; }
  bool operator<(const note x) const { return this->x < x.x; }
} tree[N * 10];
void build(int l, int r, int k) {
  if (l == r) {
    tree[k] = {a[l], l};
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, k << 1);
  build(mid + 1, r, k << 1 | 1);
  tree[k] = max(tree[k << 1], tree[k << 1 | 1]);
}
note query(int l, int r, int L, int R, int k) {
  if (l == L && R == r) return tree[k];
  int mid = (L + R) >> 1;
  if (r <= mid) return query(l, r, L, mid, k << 1);
  if (l > mid) return query(l, r, mid + 1, R, k << 1 | 1);
  return max(query(l, mid, L, mid, k << 1),
             query(mid + 1, r, mid + 1, R, k << 1 | 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &a[i]);
  build(1, n, 1);
  for (int i = n - 1; i >= 1; i--) {
    Ans[i] = n - i;
    if (a[i] == n) continue;
    note t = query(i + 1, a[i], 1, n, 1);
    int p = t.id;
    Ans[i] += Ans[p];
    Ans[i] -= (a[i] - p);
  }
  for (int i = 1; i <= n; i++) sum = sum + Ans[i];
  printf("%I64d\n", sum);
  return 0;
}
