#include <bits/stdc++.h>
using namespace std;
int N, a[100100];
long long rez, t[400400];
int ind[400400];
void update(int nod, int st, int dr, int c, long long d) {
  if (st == dr) {
    t[nod] = d;
    ind[nod] = st;
    return;
  }
  int mij = (st + dr) / 2;
  if (c <= mij) {
    update(2 * nod, st, mij, c, d);
  } else {
    update(2 * nod + 1, mij + 1, dr, c, d);
  }
  if (t[2 * nod] + ind[2 * nod] > t[2 * nod + 1] + ind[2 * nod + 1]) {
    t[nod] = t[2 * nod + 1];
    ind[nod] = ind[2 * nod + 1];
  } else {
    t[nod] = t[2 * nod];
    ind[nod] = ind[2 * nod];
  }
}
pair<long long, int> getmin(int nod, int st, int dr, int c, int d) {
  long long ret = 1000000000000;
  int in = ind[nod];
  long long mimi = 1000000000000;
  if (c <= st && dr <= d) {
    return make_pair(t[nod], ind[nod]);
  }
  int mij = (st + dr) / 2;
  if (d > mij) {
    pair<long long, int> p = getmin(nod * 2 + 1, 1 + mij, dr, c, d);
    if (p.first + p.second < mimi) {
      ret = p.first;
      in = p.second;
      mimi = ret + in;
    }
  }
  if (c <= mij) {
    pair<long long, int> p = getmin(nod * 2, st, mij, c, d);
    if (p.first + p.second < mimi) {
      ret = p.first;
      in = p.second;
      mimi = ret + in;
    }
  }
  return make_pair(ret, in);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  update(1, 1, N, N, 0);
  for (int i = N - 1; i >= 1; --i) {
    pair<long long, int> p = getmin(1, 1, N, i + 1, a[i]);
    long long val = N - i + p.first - (a[i] - p.second);
    update(1, 1, N, i, val);
    rez += val;
  }
  cout << rez;
  return 0;
}
