#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int M = 1000000007;
int n;
int a[N];
long long dp[N];
pair<int, int> data[N << 2];
void push_up(int rt) { data[rt] = max(data[rt << 1], data[rt << 1 | 1]); }
void build(int l, int r, int rt) {
  if (l == r) {
    data[rt] = make_pair(a[l], l);
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  push_up(rt);
}
pair<int, int> query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return data[rt];
  }
  int m = (l + r) >> 1;
  pair<int, int> ret = make_pair(0, 0);
  if (L <= m) {
    ret = max(ret, query(L, R, l, m, rt << 1));
  }
  if (m < R) {
    ret = max(ret, query(L, R, m + 1, r, rt << 1 | 1));
  }
  return ret;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i < n; i++) {
      scanf("%d", &a[i]);
    }
    a[n] = n;
    build(1, n, 1);
    dp[n] = 0;
    long long ans = 0;
    for (int i = n - 1; i > 0; i--) {
      int t = query(i + 1, a[i], 1, n, 1).second;
      dp[i] = dp[t] - (a[i] - t) + n - i;
      ans += dp[i];
    }
    printf("%I64d\n", ans);
  }
}
