#include <bits/stdc++.h>
using namespace std;
long long dp[1005][1005];
long long p[1005];
long long fun(long long i, long long j) {
  if (dp[i][j] != -1) return dp[i][j];
  if (i == j) return 0;
  dp[i][j] = (fun(p[i], i) + 2 + fun(i + 1, j)) % 1000000007;
  return dp[i][j];
}
void solve() {
  long long n;
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> p[i];
  }
  for (long long int i = 0; i < n + 1; i++) {
    for (long long int j = 0; j < n + 1; j++) dp[i][j] = -1;
  }
  cout << (fun(1, n) + 2 + fun(p[n], n)) % 1000000007;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
