#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct SparseTable {
 private:
  int _a[N], dp[N][20], n;

 public:
  void init(int a[], int _n) {
    n = _n;
    for (int i = (1); i <= (n); ++i) _a[i] = a[i], dp[i][0] = i;
    for (int j = 1; (1 << j) <= n; ++j)
      for (int i = 1; i + (1 << j) - 1 <= n; ++i)
        if (a[dp[i][j - 1]] < a[dp[i + (1 << (j - 1))][j - 1]])
          dp[i][j] = dp[i + (1 << (j - 1))][j - 1];
        else
          dp[i][j] = dp[i][j - 1];
  }
  int query(int i, int j) {
    int k = log2(j - i + 1);
    if (_a[dp[i][k]] < _a[dp[j - (1 << k) + 1][k]])
      return dp[j - (1 << k) + 1][k];
    return dp[i][k];
  }
};
int n, a[N];
long long dp[N];
SparseTable b;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n - 1); ++i) scanf("%d", &a[i]);
  a[n] = n;
  b.init(a, n);
  long long res = 0;
  for (int i = (n - 1); i >= (1); --i) {
    int idx = b.query(i + 1, a[i]);
    dp[i] = dp[idx] - (long long)(a[i] - idx) + (long long)(n - i);
    res += dp[i];
  }
  printf("%I64d", res);
  return 0;
}
