#include <bits/stdc++.h>
using namespace std;
const int maxn = 110000;
long long dp[maxn];
int a[maxn];
int tree[4 * maxn];
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = start;
  } else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    if (a[tree[2 * node]] >= a[tree[2 * node + 1]])
      tree[node] = tree[2 * node];
    else
      tree[node] = tree[2 * node + 1];
  }
}
int getMax(int node, int start, int end, int l, int r) {
  if (r < start || end < l) {
    return 0;
  }
  if (l <= start && end <= r) {
    return tree[node];
  }
  int mid = (start + end) / 2;
  int p1 = getMax(2 * node, start, mid, l, r);
  int p2 = getMax(2 * node + 1, mid + 1, end, l, r);
  if (a[p1] >= a[p2]) return p1;
  return p2;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  a[n] = n;
  build(1, 1, n);
  for (int i = n - 1; i >= 1; i--) {
    int j = getMax(1, 1, n, i + 1, a[i]);
    dp[i] = n - i + dp[j] - (a[i] - j);
  }
  long long s = 0;
  for (int i = 1; i < n; i++) {
    s += dp[i];
  }
  cout << s;
  return 0;
}
