#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 100005;
int arr[MAX];
pair<int, int> tree[4 * MAX];
void build(int n, int a, int b) {
  if (a == b) {
    tree[n] = make_pair(a, arr[a]);
    return;
  }
  build(2 * n, a, (a + b) / 2);
  build(2 * n + 1, (a + b) / 2 + 1, b);
  if (tree[2 * n].second > tree[2 * n + 1].second) {
    tree[n] = tree[2 * n];
  } else {
    tree[n] = tree[2 * n + 1];
  }
}
pair<int, int> query(int n, int a, int b, int i, int j) {
  if (i > b || j < a) {
    return make_pair(-1, -1);
  }
  if (i <= a && b <= j) {
    return tree[n];
  }
  pair<int, int> q1 = query(2 * n, a, (a + b) / 2, i, j);
  pair<int, int> q2 = query(2 * n + 1, (a + b) / 2 + 1, b, i, j);
  if (q1.second > q2.second) {
    return q1;
  } else {
    return q2;
  }
}
long long dp[MAX];
int main() {
  int x;
  scanf("%d", &x);
  for (int i = 0; i < x - 1; i++) {
    scanf("%d", &arr[i + 1]);
  }
  build(1, 1, x - 1);
  dp[x - 1] = 1LL;
  for (int i = x - 2; i >= 1; i--) {
    pair<int, int> val = query(1, 1, x - 1, i + 1, arr[i]);
    int k = val.first;
    dp[i] = (long long)dp[k] - (long long)arr[i] - (long long)i + (long long)x +
            (long long)k;
  }
  long long ans = 0;
  for (int i = 1; i < x; i++) {
    ans += dp[i];
  }
  cout << ans << endl;
}
