#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
int n, a[N];
long long dp[N];
pair<int, int> st[4 * N];
pair<int, int> merge(pair<int, int> le, pair<int, int> ri) {
  if (le.first >= ri.first)
    return le;
  else
    return ri;
}
void build(int p, int l, int r) {
  if (l == r) {
    st[p] = pair<int, int>(a[l], l);
    return;
  }
  int mid = (l + r) / 2;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  st[p] = merge(st[p * 2], st[p * 2 + 1]);
}
pair<int, int> query(int p, int l, int r, int x, int y) {
  if (y < l || r < x) return pair<int, int>(0, 0);
  if (x <= l && r <= y) return st[p];
  int mid = (l + r) / 2;
  pair<int, int> ret1 = query(p * 2, l, mid, x, y);
  pair<int, int> ret2 = query(p * 2 + 1, mid + 1, r, x, y);
  return merge(ret1, ret2);
}
int main() {
  scanf("%d", &n);
  a[n] = 0;
  for (int i = 1; i <= n - 1; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  long long ans = 0;
  dp[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    int l = i + 1;
    int r = a[i];
    pair<int, int> ret = query(1, 1, n, l, r);
    int makspos = ret.second;
    if (makspos == 0) makspos = n;
    dp[i] = (long long)(makspos - i) + dp[makspos] + (long long)(n - a[i]);
    ans += dp[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
