#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 3, mod = 1e9 + 7;
long long int dp[N], dps[N], res;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[1] = dps[1] = res = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == i) {
      dp[i] = 1;
    } else {
      dp[i] = ((1 + dp[a[i]] + (dps[i - 1] + mod - dps[a[i]]) % mod) % mod +
               (i + mod - a[i]) % mod) %
              mod;
    }
    dps[i] = (dps[i - 1] + dp[i]) % mod;
    res = (res + 1 + dp[i]) % mod;
  }
  cout << (res + 1) % mod << '\n';
  ;
  return 0;
}
