#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  arr[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] -= 1;
  }
  vector<long long int> dp(n + 1, 0);
  int i = 1;
  while (i != (n + 1)) {
    dp[i] = (2 * dp[i - 1] + 2 - dp[arr[i]]) % 1000000007;
    i++;
  }
  if (dp[n] < 0) dp[n] = (dp[n] + 1000000007) % 1000000007;
  cout << dp[n] << endl;
}
