#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
using namespace std;
const long long mod = 1e9 + 7;
long long dp[1011][1011];
int p[1011];
int n;
long long f(int l, int r) {
  if (l > r) return 0;
  if (dp[l][r] != -1) return dp[l][r];
  dp[l][r] = 1ll * 2 + f(p[l], l - 1) + f(l + 1, r);
  dp[l][r] %= mod;
  return dp[l][r];
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    for (j = i; j <= n; ++j) {
      dp[i][j] = -1;
    }
  }
  f(1, n);
  cout << dp[1][n] << endl;
  return 0;
}
