#include <bits/stdc++.h>
using namespace std;
int p[4000];
long long ans[4000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
  }
  for (int i = 0; i < n; ++i) {
    if (p[i] == i)
      ans[i] = 1;
    else {
      long long &a = ans[i];
      a = 0;
      for (int j = p[i]; j < i; ++j) {
        a += ans[j];
        if (a >= 1000000007LL) a -= 1000000007LL;
      }
      a += i - p[i];
      a++;
      if (a >= 1000000007LL) a -= 1000000007LL;
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res += ans[i];
    if (res >= 1000000007LL) res -= 1000000007LL;
  }
  res += n;
  if (res >= 1000000007LL) res -= 1000000007LL;
  cout << res << endl;
}
