#include <bits/stdc++.h>
using namespace std;
const long long mx = 1e5 + 66;
const long long mod = 1e9 + 7;
const long long inf = 8e18 + 66;
const int llg = 18;
const long long mxk = 31700000;
long long power(long long a, long long b, long long md) {
  if (b == 0) return 1;
  long long c = power(a, b / 2, md);
  if (b % 2)
    return c * c % md * a % md;
  else
    return c * c % md;
}
long long n, lga[mx], ans = 0, a[mx], dp[mx];
pair<long long, long long> rmq[llg][mx];
long long mxq(int x, int y) {
  long long k = lga[y - x + 1];
  auto Jafar = max(rmq[k][x], rmq[k][y - (1 << k) + 1]);
  return Jafar.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i < mx; i++) {
    lga[i] = lga[i / 2] + 1;
  }
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    rmq[0][i] = {a[i], i};
  }
  a[n] = n;
  rmq[0][n] = {n, n};
  for (int i = 1; i < llg; i++) {
    for (int j = 1; j + (1 << i) - 1 <= n; j++) {
      rmq[i][j] = max(rmq[i - 1][j], rmq[i - 1][j + (1 << (i - 1))]);
    }
  }
  long long ans = 0;
  for (int i = n - 1; i > 0; i--) {
    int x = mxq(i + 1, a[i]);
    dp[i] = dp[x] - (a[i] - x) + n - i;
    ans += dp[i];
  }
  cout << ans;
}
