#include <bits/stdc++.h>
using namespace std;
long long ans, dp[100007];
int n, a[100007], Max[100007][28];
int gotmax(int x, int y) {
  int l = log2(y - x + 1);
  return a[Max[x][l]] < a[Max[y - (1 << l) + 1][l]] ? Max[y - (1 << l) + 1][l]
                                                    : Max[x][l];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    Max[i][0] = i;
  }
  for (int i = 1; (1 << i) < n; i++)
    for (int j = 1; j + (1 << i) - 1 < n; j++)
      Max[j][i] = a[Max[j][i - 1]] < a[Max[j + (1 << i - 1)][i - 1]]
                      ? Max[j + (1 << i - 1)][i - 1]
                      : Max[j][i - 1];
  dp[n] = 0;
  for (int i = n - 1; i; i--) {
    if (a[i] == n) {
      dp[i] = 1ll * (n - i);
      ans += dp[i];
      continue;
    }
    int k = gotmax(i + 1, a[i]);
    dp[i] = dp[k] + 1ll * (n - i - a[i] + k);
    ans += dp[i];
  }
  cout << ans << endl;
}
