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