#include <bits/stdc++.h>
using namespace std;
pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
  if (a.second > b.second) return a;
  return b;
}
struct segment_tree {
  vector<pair<int, int>> tree;
  segment_tree(int n) { tree.resize(4 * n + 17); }
  void build(int a[], int v, int tl, int tr, std::ostream& out) {
    if (tl == tr) {
      tree[v] = make_pair(tl, a[tl]);
    } else {
      int tm = (tl + tr) / 2;
      build(a, 2 * v, tl, tm, out);
      build(a, 2 * v + 1, tm + 1, tr, out);
      tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
    }
  }
  pair<int, int> get(int v, int tl, int tr, int l, int r, std::ostream& out) {
    if (r < tl || l > tr) {
      return make_pair(-1, -1);
    }
    if (tl >= l && tr <= r) {
      return tree[v];
    }
    int tm = (tl + tr) / 2;
    return merge(get(2 * v, tl, tm, l, r, out),
                 get(2 * v + 1, tm + 1, tr, l, r, out));
  }
};
const int MAXN = 100 * 1000 + 7;
int a[MAXN];
int goPos[MAXN];
long long dp[MAXN];
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {}
};
void solve(std::istream& in, std::ostream& out) {
  int n;
  in >> n;
  for (int i = 1; i < n; i++) {
    in >> a[i];
  }
  a[n] = n;
  segment_tree tree(n);
  tree.build(a, 1, 1, n, out);
  for (int i = 1; i <= n; i++) {
    pair<int, int> cur = tree.get(1, 1, n, i + 1, a[i], out);
    goPos[i] = cur.first;
  }
  for (int i = n; i >= 1; i--) {
    dp[i] = a[i] - i;
    if (a[i] < n) {
      dp[i] += dp[goPos[i]] - (a[i] - goPos[i]) + (n - a[i]);
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += dp[i];
  }
  out << res;
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
