#include <bits/stdc++.h>
using namespace std;
const int max_n = 1 << 17;
const int inf = 1e9;
struct Node {
  int x, y;
  Node(int _x = 0, int _y = inf) {
    x = _x;
    y = _y;
  }
  Node operator+(Node b) {
    if (x > b.x) return *this;
    if (x == b.x)
      if (y > b.y)
        return *this;
      else
        return b;
    return b;
  }
};
struct Segment_Tree {
  vector<Node> t;
  Segment_Tree(vector<int> a) {
    t.resize(max_n * 2, Node());
    for (int i = 0; i < a.size(); i++) {
      t[i + max_n] = Node(a[i], i);
    }
    for (int i = max_n - 1; i; i--) {
      t[i] = t[i * 2] + t[i * 2 + 1];
    }
  }

 public:
  int get(int l, int r) { return get_que(0, max_n - 1, l, r, 1).y; }

 private:
  Node get_que(int tl, int tr, int l, int r, int v) {
    if (tr < l || tl > r) {
      return Node();
    }
    if (tl >= l && tr <= r) {
      return t[v];
    }
    return get_que(tl, (tl + tr) / 2, l, r, v * 2) +
           get_que((tl + tr) / 2 + 1, tr, l, r, v * 2 + 1);
  }
};
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    a[i]--;
  }
  a[n - 1] = n - 1;
  vector<long long> dp(n, 0);
  Segment_Tree t(a);
  long long ans = 0;
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    int q = t.get(i + 1, a[i]);
    dp[i] = dp[q] + (n - i - 1) - (a[i] - q);
    ans += dp[i];
  }
  cout << ans << '\n';
}
