#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[2][1010];
int f[1010];
int p[1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    dp[0][i] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    f[i] ^= 1;
    int g = f[i];
    if (g == 0) {
      dp[g][i] = 1;
      ans += 1;
      continue;
    }
    dp[g][i] += 1;
    for (int j = p[i]; j <= i; j++) {
      f[j] ^= 1;
      dp[g][i] += dp[f[j]][j];
      dp[g][i] %= mod;
      f[j] = 0;
    }
    ans += dp[1][i];
    ans %= mod;
    f[i] = 0;
  }
  printf("%d\n", ans);
  return 0;
}
