#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main(int argc, const char *argv[]) {
  int N;
  long long int ans;
  while (cin >> N) {
    vector<int> data;
    data.assign(N + 1, 0);
    vector<int> csum;
    csum.assign(N + 1, 0);
    for (int i = 1; i <= N; i++) cin >> data[i];
    long long int res = 0LL;
    for (int i = 1; i <= N; i++) {
      ans = 2LL;
      for (int j = data[i]; j < i; j++) ans = (ans + csum[j]) % MOD;
      csum[i] = ans;
      res = (res + csum[i]) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}
