#include <bits/stdc++.h>
using namespace std;
const int P = 1000000007;
long long f[1002][1002];
int n, a[1001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, 0, sizeof(f));
  f[1][1] = 0;
  for (int i = 2; i <= n + 1; i++) {
    for (int j = 1; j <= a[i - 1]; j++)
      f[j][i] += f[j][a[i - 1]] + f[a[i - 1]][i - 1] * 2 % P + 2, f[j][i] %= P;
    for (int j = a[i - 1] + 1; j < i; j++) {
      f[j][i] += f[a[i - 1]][i - 1] * 2 % P + 2;
      f[j][i] %= P;
      f[j][i] -= f[a[i - 1]][j];
      if (f[j][i] < 0) f[j][i] += P;
    }
  }
  printf("%d\n", f[1][n + 1]);
}
