#include <bits/stdc++.h>
using namespace std;
class seg_max_index {
 public:
  int n, size;
  vector<long long> arr;
  vector<int> hai;
  long long inf;
  seg_max_index(int size) : n(size / 2), inf(-(1LL << 60)) {
    arr.resize(n);
    hai.resize(n * 2);
    fill(arr.begin(), arr.end(), inf);
    this->size = size;
    for (int i = n; i < size; i++) hai[i] = i - n;
  }
  void update(int i, long long v) {
    arr[i] = v;
    i += n;
    while (i > 1) {
      i /= 2;
      hai[i] =
          arr[hai[2 * i]] > arr[hai[2 * i + 1]] ? hai[2 * i] : hai[2 * i + 1];
    }
  }
  int range_max_index(int left, int right) {
    if (left > right) return -1;
    int res = left;
    left += n, right += n;
    for (; left <= right; left = (left + 1) >> 1, right = (right - 1) >> 1) {
      if (left & 1) {
        if (arr[res] < arr[hai[left]]) res = hai[left];
      }
      if ((right & 1) == 0) {
        if (arr[res] < arr[hai[right]]) res = hai[right];
      }
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<long long> dp(n - 1);
  seg_max_index seg(1 << 20);
  for (int i = 0; i < n - 1; i++) seg.update(i, a[i]);
  dp[n - 2] = 1;
  long long res = 1;
  for (int i = n - 3; i >= 0; i--) {
    int ind = seg.range_max_index(i + 1, a[i]);
    dp[i] = a[i] - i + dp[ind] - (a[i] - ind) + (n - a[i] - 1);
    res += dp[i];
  }
  cout << res << "\n";
  return 0;
}
