#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], dp[100005], seg[400005], l, r;
long long sum;
void update(int st, int en, int pos) {
  if (st > r || en < l) return;
  if (st == en) {
    seg[pos] = dp[st] + st + 1;
    return;
  }
  int mid = (st + en) / 2;
  update(st, mid, pos * 2 + 1);
  update(mid + 1, en, pos * 2 + 2);
  seg[pos] = min(seg[pos * 2 + 1], seg[pos * 2 + 2]);
}
long long query(int st, int en, int pos) {
  if (st > r || en < l) return 1e18;
  if (st >= l && en <= r) return seg[pos];
  int mid = (st + en) / 2;
  long long p1 = (query(st, mid, pos * 2 + 1));
  long long p2 = (query(mid + 1, en, pos * 2 + 2));
  return min(p1, p2);
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  dp[n - 2] = 1;
  l = r = n - 2;
  update(0, n - 2, 0);
  sum += dp[n - 2];
  for (int i = n - 3; i >= 0; i--) {
    l = i + 1;
    r = a[i] - 1;
    dp[i] = query(0, n - 2, 0) + n - i - a[i] - 1;
    l = r = i;
    update(0, n - 2, 0);
    sum += dp[i];
  }
  cout << sum;
  return 0;
}
