#include <bits/stdc++.h>
using namespace std;
stringstream ss;
long long mod = 1000000007LL;
long long dp[1024];
int par[1024];
long long f(int x) {
  long long ans = 2;
  while (x != par[x]) {
    int y = par[x];
    for (int i = y + 1; i < x; i++) ans = (ans + dp[i]) % mod;
    ans = (ans + 2) % mod;
    x = y;
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> par[i];
  long long total = 0;
  dp[1] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = f(i);
    total = (total + dp[i]) % mod;
  }
  cout << total << endl;
  return 0;
}
