#include <bits/stdc++.h>
using namespace std;
const int mx = (int)1e5 + 100;
deque<int> q;
long long sum[mx];
int n, to[mx];
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) scanf("%d", &to[i]);
  long long as = 0;
  q.push_back(n - 1), sum[n - 1] = as = 1;
  for (int i = n - 2; i; --i) {
    int x = upper_bound(q.begin(), q.end(), to[i]) - q.begin() - 1;
    sum[i] = n - i + sum[q[x]] - (to[i] - q[x]);
    as += sum[i];
    while (!q.empty() && to[i] >= to[q.front()]) q.pop_front();
    q.push_front(i);
  }
  cout << as << endl;
  return 0;
}
