#include <bits/stdc++.h>
using namespace std;
vector<long long int> lol(10005, 0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, i;
  cin >> n;
  long long int arr[n + 1];
  long long int to = 2;
  for (long long int i = 1; i <= n; ++i) cin >> arr[i];
  for (long long int i = 2; i <= n + 1; i++) {
    lol[i] = (2 * lol[i - 1] + to - lol[arr[i - 1]]) % 1000000007;
    if (lol[i] < 0) lol[i] += 1000000007;
  }
  cout << lol[n + 1];
  return 0;
}
