#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
vector<int32_t> p_i;
vector<uint64_t> steps;
vector<bool> steps_found;
void brute_force(vector<bool>& odd_state, uint32_t idx, uint64_t& count) {
  uint32_t end = p_i.size();
  uint32_t trace_idx = 0;
  uint64_t trace_count = 0;
  bool tracing = false;
  while (idx != end) {
    ++count;
    count %= 1000000007UL;
    odd_state[idx] = !odd_state[idx];
    if (tracing && trace_idx == idx) {
      if (trace_count > count) {
        count += 1000000007;
      }
      steps[idx] = (count - trace_count) % 1000000007UL;
      steps_found[idx] = true;
      tracing = false;
    }
    if (odd_state[idx]) {
      if (steps_found[idx]) {
        count += steps[idx];
        count %= 1000000007UL;
        odd_state[idx] = false;
        ++idx;
      } else {
        trace_idx = idx;
        trace_count = count;
        tracing = true;
        idx = p_i[idx];
      }
    } else {
      ++idx;
    }
  }
}
void long_path(istream& in, ostream& out) {
  uint32_t n, i = 0;
  in >> n;
  p_i.resize(n);
  steps.resize(n);
  steps_found.resize(n);
  vector<bool> odd_state(n);
  while (i < n) {
    int32_t new_p_i;
    in >> new_p_i;
    p_i[i] = new_p_i - 1;
    ++i;
  }
  uint64_t count = 0;
  brute_force(odd_state, 0, count);
  out << count % 1000000007UL << endl;
}
int main(int argc, char* argv[]) {
  long_path(cin, cout);
  return 0;
}
