#include <bits/stdc++.h>
using namespace std;
const int INFint = 2147483547;
const long long INF = 2223372036854775807ll;
const long long MOD = 1000000007ll;
class SegmentTree {
 public:
  int n;
  vector<pair<int, int> > t;
  void build(vector<int> &v) {
    for (int i = 0; i < n; i++) t[i + n] = {v[i], i};
    for (int i = n - 1; i > 0; i--) t[i] = max(t[i << 1], t[i << 1 | 1]);
  }
  pair<int, int> query(int l, int r) {
    pair<int, int> res = {-1, -1};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = max(res, t[l++]);
      if (r & 1) res = max(res, t[--r]);
    }
    return res;
  }
  SegmentTree(int n) : n(n) { t.resize(n << 1, {-1, -1}); }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  a[n - 1] = n - 1;
  SegmentTree sg(n);
  sg.build(a);
  vector<long long> dp(n);
  dp[n - 1] = 0;
  for (int i = n - 2; i > -1; i--) {
    int mx = sg.query(i + 1, a[i] + 1).second;
    dp[i] = mx - a[i] + dp[mx] + n - i - 1;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += dp[i];
  cout << ans;
  fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
  ;
  return 0;
}
