#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 11;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const long long MOD = 1e9 + 7;
long long read() {
  long long x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long dp[MAXN][MAXN], p[MAXN];
long long DP(int i, int j) {
  if (i == j) return dp[i][j] = 1;
  if (~dp[i][j]) return dp[i][j];
  if (i < 0 || j < 0) return 0;
  long long res = 0;
  res = (DP(i, j - 1) % MOD + DP(p[j - 1], j - 1) % MOD + 1) % MOD;
  return dp[i][j] = res;
}
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) p[i] = read();
    memset(dp, -1, sizeof dp);
    cout << (DP(1, n + 1) % MOD - 1 + MOD) % MOD << endl;
  }
  return 0;
}
