#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5 + 5;
int n;
int a[nmax];
int aib[nmax];
long long dp[nmax];
int query(int x) {
  int mx = 0;
  while (x) {
    if (a[aib[x]] > a[mx]) mx = aib[x];
    x -= (x & -x);
  }
  return mx;
}
void update(int x, int v) {
  while (x < nmax) {
    if (a[aib[x]] < a[v]) aib[x] = v;
    x += (x & -x);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  a[n] = n;
  update(n, n);
  long long ans = 0;
  for (int i = n - 1; i >= 1; i--) {
    int next = query(a[i]);
    int between = a[i] - next;
    dp[i] = dp[next] - between + n - i;
    update(i, i);
    ans += dp[i];
  }
  return 0 * printf("%I64d\n", ans);
}
