#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1000000000000;
const double eps = (double)1e-8;
const int mod = (int)1000000007;
const int maxn = (int)1e5 + 5;
long long ans;
int a[maxn], d[maxn], t[4 * maxn], n, x, y;
void build(int v, int l, int r) {
  if (l > r) return;
  if (l == r) {
    t[v] = l;
    return;
  }
  int m = (l + r) / 2;
  build(2 * v, l, m);
  build(2 * v + 1, m + 1, r);
  if (a[t[2 * v]] > a[t[2 * v + 1]])
    t[v] = t[2 * v];
  else
    t[v] = t[2 * v + 1];
  return;
}
int dzen(int v, int l, int r, int tl, int tr) {
  if (tl > tr || l > r) return 0;
  if (l == tl && r == tr) {
    return t[v];
  }
  int m = (l + r) / 2;
  int x, y;
  x = dzen(2 * v, l, m, tl, min(m, tr));
  y = dzen(2 * v + 1, m + 1, r, max(m + 1, tl), tr);
  if (a[x] > a[y])
    return x;
  else
    return y;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = (1); i <= (n - 1); i++) {
    cin >> a[i];
    d[i] = 1;
  }
  a[0] = 0;
  a[n] = n + 1;
  build(1, 1, n);
  ans = 0;
  for (int i = (1); i <= (n - 1); i++) {
    x = dzen(1, 1, n, i + 1, a[i]);
    ans += (long long)d[i] * (long long)(x - i) +
           (long long)d[i] * (long long)(n - a[i]);
    d[x] += d[i];
  }
  cout << ans << "\n";
  return 0;
}
