#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> mine(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    cin >> mine[i];
  }
  long long time = 0;
  vector<long long> dp(n + 1, -1);
  vector<long long> visit(n + 1, -1);
  long long pos = 1;
  while (pos != n + 1) {
    if (dp[pos] != -1) {
      time = (time + dp[pos]) % 1000000007;
      pos++;
    } else {
      if (visit[pos] == -1) {
        visit[pos] = time % 1000000007;
        pos = mine[pos];
      } else {
        dp[pos] = (time - visit[pos]) % 1000000007;
        if (dp[pos] < 0) dp[pos] += 1000000007;
        pos++;
      }
    }
    time = (time + 1) % 1000000007;
  }
  cout << time << endl;
  return 0;
}
