#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897;
const long long mod = 1e9 + 7;
const int M = 100005;
const long long INF = 1e9 + 5;
int solve() {
  int n;
  cin >> n;
  n++;
  long long p[n + 1], dp[n + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i < n; i++) cin >> p[i];
  dp[2][1] = 2;
  for (int i = 3; i <= n; i++) {
    dp[i][i - 1] = (2 + dp[i - 1][p[i - 1]]) % mod;
    for (int j = i - 2; j > 0; j--) {
      dp[i][j] = (dp[i - 1][j] + dp[i][i - 1]) % mod;
    }
  }
  cout << dp[n][1];
  return 0;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int t = 1, i = 1;
  while (t--) {
    solve();
  }
  return 0;
}
