#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
pair<long long, long long> a[3 * MAX];
long long dp[MAX];
long long n;
void build() {
  for (int i = n - 1; i > 0; i--) a[i] = max(a[i << 1], a[i << 1 | 1]);
}
long query(int l, int r) {
  pair<long long, long long> res = make_pair(-1, -1);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = max(a[l++], res);
    if (r & 1) res = max(a[--r], res);
  }
  return res.second;
}
int main() {
  cin >> n;
  n--;
  for (int i = 0; i < n; i++) {
    long long b;
    cin >> b;
    a[i + n] = make_pair((b - 1), i);
  }
  a[2 * n - 1] = make_pair(n - 1, n - 1);
  build();
  long long sum = 0;
  dp[n] = 0;
  for (long long i = n - 2; i >= 0; i--) {
    long long m = query(i + 1, a[n + i].first + 1);
    dp[i] = dp[m] - (a[n + i].first - m) + n - i;
    sum += dp[i];
  }
  cout << (sum + n) << endl;
  return 0;
}
