#include <bits/stdc++.h>
using namespace std;
inline long long Abs(long long x) {
  if (x > 0) return x;
  return -x;
}
inline long long Min(long long x, long long y) { return x < y ? x : y; }
inline long long Max(long long x, long long y) { return x > y ? x : y; }
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long a[100005], f[100005];
struct SegMentTree {
  pair<long long, long long> Tree[100005 << 2];
  void Build(long long x, long long l, long long r) {
    long long Mid = (l + r) / 2;
    if (l == r) {
      Tree[x] = pair<long long, long long>(a[Mid], Mid);
      return;
    }
    Build(x << 1, l, Mid);
    Build(x << 1 | 1, Mid + 1, r);
    if (Tree[x << 1] > Tree[x << 1 | 1])
      Tree[x] = Tree[x << 1];
    else
      Tree[x] = Tree[x << 1 | 1];
  }
  pair<long long, long long> Query(long long x, long long l, long long r,
                                   long long Ql, long long Qr) {
    if (l == r) return Tree[x];
    if (Ql <= l && r <= Qr) return Tree[x];
    long long Mid = (l + r) / 2;
    if (Qr <= Mid)
      return Query(x << 1, l, Mid, Ql, Qr);
    else if (Ql > Mid)
      return Query(x << 1 | 1, Mid + 1, r, Ql, Qr);
    else {
      pair<long long, long long> La = Query(x << 1, l, Mid, Ql, Mid);
      pair<long long, long long> Ra =
          Query(x << 1 | 1, Mid + 1, r, Mid + 1, Qr);
      if (La > Ra) return La;
      return Ra;
    }
  }
} _;
long long Ans;
int main() {
  long long n;
  read(n);
  for (register int i = 1; i < n; ++i) read(a[i]);
  _.Build(1, 1, n);
  for (register int i = n - 1; i >= 1; --i) {
    long long k = _.Query(1, 1, n, i + 1, a[i]).second;
    f[i] = f[k] + n + k - a[i] - i;
    Ans += f[i];
  }
  printf("%lld", Ans);
  return 0;
}
