#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
int a[maxn], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; ++i) scanf("%d", a + i);
  long long ans = 0;
  deque<pair<long long, long long> > dq(1, make_pair(n, n));
  for (int i = n - 1; i >= 1; --i) {
    auto it = lower_bound(dq.begin(), dq.end(),
                          (pair<long long, long long>)make_pair(a[i] + 1, 0));
    assert(it != dq.begin());
    --it;
    long long dp = n - i - a[i] + it->second;
    ans += dp;
    auto pr = make_pair(i, i + dp);
    while (!dq.empty() && dq.front().second >= pr.second) dq.pop_front();
    dq.push_front(pr);
  }
  printf("%lld\n", ans);
}
