#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
pair<long long int, int> MAX[maxn << 2], a[maxn], m;
long long int dp[maxn] = {0}, ll;
void PushUP(int rt) { MAX[rt] = max(MAX[rt << 1], MAX[rt << 1 | 1]); }
void build(int l, int r, int rt) {
  if (l == r) {
    MAX[rt] = a[ll++];
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  PushUP(rt);
}
pair<int, int> query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return MAX[rt];
  }
  int m = (l + r) >> 1;
  pair<int, int> ret;
  if (L <= m) {
    ret = max(ret, query(L, R, l, m, rt << 1));
  }
  if (R > m) ret = max(ret, query(L, R, m + 1, r, rt << 1 | 1));
  return ret;
}
int main() {
  int n, i;
  long long int ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n - 1; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  a[n].first = n, a[n].second = n;
  ll = 1;
  build(1, n, 1);
  dp[n] = 0;
  for (i = n - 1; i >= 1; i--) {
    m = query(i + 1, a[i].first, 1, n, 1);
    dp[i] += dp[m.second] - (a[i].first - m.second) + n - i;
  }
  for (i = 1; i <= n - 1; i++) {
    ans += dp[i];
  }
  printf("%I64d\n", ans);
}
