#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int arr[1003];
  long long int index[1003];
  long long int i, n, s;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[i];
  for (i = 1; i <= n; i++) index[i] = -1;
  index[1] = 0;
  i = 1;
  s = 0;
  while (i <= n) {
    if (index[arr[i]] == -1) {
      s++;
      index[arr[i]] = s;
      i = arr[i];
    } else {
      s = (s + s - index[arr[i]] + 2) % 1000000007;
      if (s < 0) s = s + 1000000007;
      index[i + 1] = s;
      i = i + 1;
    }
  }
  cout << s % 1000000007;
  return 0;
}
