#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int xx;
  void assLeaf(int a, int pos) {
    x = a;
    xx = pos;
  }
  void merge(node l, node r) {
    x = max(l.x, r.x);
    xx = r.xx;
    if (x == l.x) xx = l.xx;
  }
};
class segTree {
  int N;
  node* A;

 public:
  void init(int n, int a[]) {
    int sz;
    for (sz = 0; (1 << sz) <= n; sz++)
      ;
    sz = 1 << sz;
    sz = 2 * sz;
    N = sz;
    A = new node[N];
    build(1, 0, n - 1, a);
  }
  void build(int ind, int L, int R, int a[]) {
    if (L == R) {
      A[ind].assLeaf(a[L], L);
      return;
    }
    int left, right, mid;
    left = 2 * ind;
    right = left + 1;
    mid = (L + R) >> 1;
    build(left, L, mid, a);
    build(right, mid + 1, R, a);
    A[ind].merge(A[left], A[right]);
  }
  node query(int ind, int L, int R, int x, int y, int a[]) {
    if (x == L && y == R) return A[ind];
    int mid = (L + R) >> 1;
    if (y <= mid)
      return query(2 * ind, L, mid, x, y, a);
    else if (x > mid)
      return query(2 * ind + 1, mid + 1, R, x, y, a);
    node left = query(2 * ind, L, mid, x, mid, a);
    node right = query(2 * ind + 1, mid + 1, R, mid + 1, y, a);
    node ans;
    ans.merge(left, right);
    return ans;
  }
};
int main() {
  int n;
  cin >> n;
  int a[n];
  int i;
  for (i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  a[n - 1] = n - 1;
  segTree ped;
  ped.init(n, a);
  long long dp[n];
  dp[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) {
    node M = ped.query(1, 0, n - 1, i + 1, a[i], a);
    int m = M.xx;
    dp[i] = dp[m] - (a[i] - m) + n - i - 1;
  }
  long long ans = 0;
  for (i = 0; i < n; i++) ans += dp[i];
  cout << ans << endl;
  return 0;
}
