#include <bits/stdc++.h>
using namespace std;
int n;
int p[1001];
int dp[1001][1001];
int solve(int i, int j) {
  if (i == n || i == j) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  if (p[i] - 1 == i)
    return dp[i][j] = (2 + solve(i + 1, j) % 1000000007) % 1000000007;
  else
    return dp[i][j] = (2 + solve(p[i] - 1, i) % 1000000007 +
                       solve(i + 1, j) % 1000000007) %
                      1000000007;
}
int main() {
  cin >> n;
  fill(&dp[0][0], &dp[n + 1][0], -1);
  for (int i = 0; i < n; i++) cin >> p[i];
  cout << solve(0, n);
}
