#include <bits/stdc++.h>
using namespace std;
int n, backRoom[1005], dp[1005][1005], backSteps[1005];
int go(int pos, int maxPos) {
  long long res = 0;
  if (pos == maxPos || pos == n + 1) return 0;
  if (~dp[pos][maxPos]) return dp[pos][maxPos];
  if (pos < maxPos)
    res = (long long)backSteps[pos] + 1 + go(pos + 1, maxPos);
  else {
    backSteps[pos] = go(backRoom[pos], pos) + 1;
    res = (long long)backSteps[pos] + 1 + go(pos + 1, pos);
  }
  return dp[pos][maxPos] = res % 1000000007;
}
int main() {
  int i, r, nr, moves = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &backRoom[i]);
  backRoom[n + 1] = 0;
  memset((dp), (-1), sizeof(dp));
  cout << go(1, 0) << endl;
  return 0;
}
