#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const int INF = 1e9 + 1;
const long long INFL = 1e18 + 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long n, a[N], dp[N], sum;
pair<int, int> t[4 * N];
void build(int v = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    t[v].first = a[tl];
    t[v].second = tl;
    return;
  }
  int tm = (tl + tr) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm + 1, tr);
  t[v].first = max(t[v * 2].first, t[v * 2 + 1].first);
  t[v].second = (t[v * 2].first > t[v * 2 + 1].first ? t[v * 2].second
                                                     : t[v * 2 + 1].second);
}
pair<int, int> get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return make_pair(0, 0);
  if (l <= tl && tr <= r) return t[v];
  int tm = (tl + tr) >> 1;
  return max(get(l, r, v * 2, tl, tm), get(l, r, v * 2 + 1, tm + 1, tr));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  build();
  for (int i = n - 2; i >= 0; i--) {
    int id = get(i + 1, a[i]).second;
    dp[i] = dp[id] + (n - i) - (a[i] - id);
    sum += dp[i];
  }
  cout << sum - 1;
  return 0;
}
