#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
int n;
int x[MAXN - 1];
long long sum[MAXN];
int bmx[MAXN + 1];
int bidx[MAXN + 1];
int bget(int idx) {
  int ret = -1;
  for (++idx; idx > 0; idx -= idx & -idx) {
    if (bidx[idx] != -1 && (ret == -1 || bmx[idx] > bmx[ret + 1]))
      ret = bidx[idx];
  }
  return ret;
}
void bset(int idx, int val) {
  int oidx = idx;
  for (++idx; idx <= n; idx += idx & -idx) {
    if (bidx[idx] == -1 || val > bmx[idx]) bmx[idx] = val, bidx[idx] = oidx;
  }
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); ++i) scanf("%d", &x[i]), --x[i];
  long long ret = 0;
  sum[n - 1] = 0;
  memset(bidx, -1, sizeof(bidx));
  for (int i = n - 2; i >= 0; --i) {
    sum[i] = n - i - 1;
    if (x[i] != n - 1) {
      int j = bget(x[i]);
      sum[i] += sum[j] - (x[i] - j);
    }
    ret += sum[i];
    bset(i, x[i]);
  }
  printf("%I64d\n", ret);
}
int main() {
  run();
  return 0;
}
