#include <bits/stdc++.h>
using namespace std;
struct SegTree {
  pair<int, int> op(pair<int, int> x, pair<int, int> y) {
    if (x.first > y.first)
      return x;
    else
      return y;
  }
  int n;
  vector<pair<int, int> > t;
  void init(vector<int> a) {
    n = (int)(a.size());
    t.resize(2 * n);
    for (int i = 0; i < n; i++) t[n + i] = make_pair(a[i], i);
    for (int i = n - 1; i > 0; i--) t[i] = op(t[i << 1], t[i << 1 | 1]);
  }
  void modify(int p, pair<int, int> value) {
    for (t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = op(t[p], t[p ^ 1]);
  }
  pair<int, int> query(int l, int r) {
    pair<int, int> res = make_pair(0, 0);
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = op(res, t[l++]);
      if (r & 1) res = op(res, t[--r]);
    }
    return res;
  }
} ST;
int n;
vector<int> a;
vector<long long> dp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  a.resize(n);
  dp.resize(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  a[n - 1] = n - 1;
  ST.init(a);
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    int best = ST.query(i + 1, a[i] + 1).second;
    dp[i] = dp[best] - a[i] + best + n - i - 1;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[i];
  }
  cout << ans << '\n';
  return 0;
}
