#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> p(n + 2, 0);
  vector<long long> v(n + 2, 0);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  long long i = 1, cnt = 0, mod = 1000000007;
  while (i != n + 1) {
    long long s = 1;
    for (int j = p[i]; j <= i; j++) {
      s = (s + v[j]) % mod;
    }
    s = (s + i - p[i]) % mod;
    v[i] = s;
    cnt += s + 1;
    cnt %= mod;
    i++;
  }
  cout << cnt << endl;
  return 0;
}
