#include <bits/stdc++.h>
char putnb[20];
using namespace std;
const long long mod = 1e9 + 7;
const long long mod2 = 1999999973;
const int infs = 1e8;
const long long inf = 1e18;
const int N = 100000;
long long p[1005];
int n;
long long ans = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int pi;
    cin >> pi;
    if (pi == i) {
      p[i] = 2;
      for (int j = 1; j <= i - 1; ++j) p[j] += 2, p[j] %= mod;
    } else {
      p[i] = 2 + p[pi];
      p[i] %= mod;
      int curr = p[pi];
      for (int j = 1; j <= i - 1; ++j) p[j] += 2 + curr, p[j] %= mod;
    }
    ans += p[i];
    ans %= mod;
  }
  cout << ans;
  return 0;
}
