#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, LIMIT = 1e9 + 7;
pair<int, int> it[4 * N];
long long a[N], dp[N];
long long n, ans = 0;
void Read() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> a[i];
  }
}
void Build(long long id, long long l, long long r) {
  if (l == r) {
    it[id] = pair<int, int>(a[l], l);
    return;
  }
  long long m = (l + r) >> 1;
  Build(id * 2, l, m);
  Build(id * 2 + 1, m + 1, r);
  if (it[id * 2].first > it[id * 2 + 1].first) {
    it[id] = it[id * 2];
  } else {
    it[id] = it[id * 2 + 1];
  }
}
pair<int, int> Get(long long id, long long l, long long r, long long u,
                   long long v) {
  if (l > v || r < u) {
    return pair<int, int>(-1, -1);
  }
  if (l >= u && r <= v) {
    return it[id];
  }
  long long m = (l + r) >> 1;
  pair<int, int> p1 = Get(id * 2, l, m, u, v),
                 p2 = Get(id * 2 + 1, m + 1, r, u, v);
  if (p1.first > p2.first) {
    return p1;
  } else {
    return p2;
  }
}
void Process() {
  dp[n] = 0;
  for (int i = n - 1; i >= 1; --i) {
    long long m = Get(1, 1, n, i + 1, a[i]).second;
    dp[i] = dp[m] - (a[i] - m) + n - i;
    ans += dp[i];
  }
  cout << ans;
}
int main() {
  Read();
  Build(1, 1, n);
  Process();
  return 0;
}
