#include <bits/stdc++.h>
using namespace std;
const int inf = 111111111;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
}
long long mulmod(long long a, long long b, long long m) {
  long long q = (long long)(((long double)a * (long double)b) / (long double)m);
  long long r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T>
T mod(T a, T b) {
  while (a < 0) a += b;
  return a % b;
}
template <typename T>
T power(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mod(x * p, m);
    p = mod(p * p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T power(T e, T n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T InverseEuler(T a, T m) {
  return (a == 1 ? 1 : power(a, m - 2, m));
}
template <typename T>
T gcd(T a, T b) {
  return __gcd(a, b);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
int exEuler(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int x1, y1;
  int g = exEuler(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return g;
}
long long dp[100003];
int st[100003 << 2];
int n;
int a[100003];
void build(int p = 1, int l = 1, int r = n) {
  if (l == r) {
    st[p] = l;
    return;
  }
  int m = (l + r) >> 1;
  build(p << 1, l, m);
  build(p << 1 | 1, m + 1, r);
  st[p] = st[p << 1];
  if (a[st[p << 1 | 1]] > a[st[p]]) st[p] = st[p << 1 | 1];
}
int rmq(int ql, int qr, int p = 1, int l = 1, int r = n) {
  if ((ql > r) or (qr < l)) return (n + 1);
  if (ql <= l and r <= qr) {
    return st[p];
  }
  int m = (l + r) >> 1;
  int ll = rmq(ql, qr, p << 1, l, m);
  int rr = rmq(ql, qr, p << 1 | 1, m + 1, r);
  if (a[ll] > a[rr]) return ll;
  return rr;
}
int main(int argc, char *argv[]) {
  io();
  cin >> n;
  for (__typeof(n - 1) i = 1; i <= n - 1; ++i) {
    cin >> a[i];
  }
  a[n] = n;
  a[n + 1] = -1;
  build();
  dp[n] = 0;
  for (__typeof(1) i = n - 1; i >= 1; --i) {
    int m = rmq(i + 1, a[i]);
    dp[i] = dp[m] - (a[i] - m) + (n - i);
  }
  long long ans = 0;
  for (__typeof(n) i = 1; i <= n; ++i) {
    ans += dp[i];
  }
  cout << ans << '\n';
  return 0;
}
