#include <bits/stdc++.h>
using namespace std;
int n, P[1005];
bool A[1005];
int H[1005];
int dp[1005];
int main() {
  +scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", P + i);
  int pos = 1, tm = 0;
  stack<int> S;
  while (pos <= n) {
    tm = (tm + 1) % (1000000007);
    if (H[pos] == 1) {
      if (!dp[pos]) {
        dp[pos] = ((tm - S.top()) % (1000000007) + (1000000007)) % (1000000007);
      }
      S.pop();
      H[pos] = -1;
    } else {
      S.push(tm);
      H[pos] = 1;
    }
    A[pos] = !A[pos];
    if (A[pos]) {
      if (dp[pos]) {
        tm = ((tm + dp[pos] - 1) % (1000000007) + (1000000007)) % (1000000007);
      } else
        pos = P[pos];
    } else {
      pos++;
    }
  }
  cout << tm << endl;
  return 0;
}
