#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int inf = 1 << 30;
const int maxn = 200500;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
void err(int x) {
  printf("%d\n", x);
  exit(0);
}
const int K = 20;
int mi[maxn][K], lo[maxn];
int n, m;
int a[maxn];
void build() {
  lo[1] = 0;
  for (int i = (2); i < (int)(maxn); ++i) lo[i] = lo[i / 2] + 1;
  for (int i = 0; i < (int)(n); ++i) {
    mi[i][0] = i;
  }
  for (int j = (1); j < (int)(K); ++j)
    for (int i = 0; i + (1 << j) <= n; i++) {
      int c = mi[i][j - 1], d = mi[i + (1 << (j - 1))][j - 1];
      mi[i][j] = (a[c] > a[d] ? c : d);
    }
}
int ge(int L, int R) {
  int j = lo[R - L + 1];
  int c = mi[L][j], d = mi[R - (1 << j) + 1][j];
  return (a[c] > a[d] ? c : d);
}
long long d[maxn];
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n - 1); ++i) scanf("%d", &a[i]), --a[i];
  a[n - 1] = n - 1;
  d[n - 1] = 0;
  build();
  long long ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    int mxi = ge(i, a[i]);
    d[i] = d[mxi] + (n - i - 1) - (a[i] - mxi);
    ans += d[i];
  }
  printf("%lld\n", ans);
}
int main() {
  int tc = 1;
  for (int tt = 0; tt < (int)(tc); ++tt) {
    solve();
  }
}
