#include <bits/stdc++.h>
using namespace std;
int N, a, b, c, m;
int K;
long long dp[1000007];
int in[1000007];
int Tr[4 * 1000007];
struct sgs {
  sgs *l, *r;
  int val;
  sgs() {
    val = 1000007;
    l = r = NULL;
  }
};
void addit(int v = 1, int tl = 1, int tr = N - 1) {
  if (tl == tr) {
    Tr[v] = tl;
    return;
  }
  int mid = (tl + tr) / 2;
  addit(v + v, tl, mid);
  addit(v + v + 1, mid + 1, tr);
  Tr[v] = in[Tr[v + v]] > in[Tr[v + v + 1]] ? Tr[v + v] : Tr[v + v + 1];
}
int get(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) {
    return -1;
  }
  if (tl >= l && tr <= r) {
    return Tr[v];
  }
  int mid = (tl + tr) / 2;
  int A = get(v + v, tl, mid, l, r);
  int B = get(v + v + 1, mid + 1, tr, l, r);
  if (A == -1) return B;
  if (B == -1) return A;
  return in[A] >= in[B] ? A : B;
}
sgs *root;
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) scanf("%d", &in[i]);
  dp[N - 1] = 1;
  addit(1, 1, N - 1);
  long long pas = 1;
  for (int i = N - 2; i >= 1; i--) {
    int j = get(1, 1, N - 1, i + 1, in[i]);
    dp[i] = dp[j] + (N - i) - (in[i] - j);
    pas += dp[i];
  }
  printf("%I64d\n", pas);
  return 0;
}
