#include <bits/stdc++.h>
using namespace std;
const int MAX = (1 << 18);
int n;
int aa[100007];
pair<int, int> tree[2 * MAX + 7];
long long dp[100007];
void update(int e, pair<int, int> v) {
  int ve = e + MAX;
  while (ve) tree[ve] = max(tree[ve], v), ve /= 2;
}
int query(int a, int b) {
  int va = a + MAX, vb = b + MAX;
  pair<int, int> res = max(tree[va], tree[vb]);
  while (va / 2 != vb / 2) {
    if (va % 2 == 0) res = max(res, tree[va + 1]);
    if (vb % 2 == 1) res = max(res, tree[vb - 1]);
    va /= 2, vb /= 2;
  }
  return res.second;
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &aa[i]);
  update(n, {n, n});
  long long res = 0;
  for (int i = n - 1; i; i--) {
    int x = query(i + 1, aa[i]);
    dp[i] = dp[x] + n - i - (aa[i] - x);
    res += dp[i];
    update(i, {aa[i], i});
  }
  printf("%lld\n", res);
}
int main() {
  solve();
  return 0;
}
