#include <bits/stdc++.h>
using namespace std;
const int MX = 1000;
const int modd = 1000 * 1000 * 1000 + 7;
int n;
int p[MX + 1];
int fw[MX + 1], fwint[MX + 1];
void addVal(int* fenw, int pos, int v) {
  if (pos <= 0) return;
  for (; pos <= MX; pos += pos & -pos) {
    fenw[pos] += v;
  }
}
int getSum(int* fenw, int pos) {
  int sum = 0;
  for (; pos; pos -= pos & -pos) {
    sum += fenw[pos];
  }
  return sum;
}
void setToZero(int from, int to) {
  if (to < from) return;
  int len = to - from + 1;
  addVal(fw, from, +(from - 1));
  addVal(fwint, from, -1);
  addVal(fw, to + 1, -(from - 1) - len);
  addVal(fwint, to + 1, +1);
}
int getPref(int pos) {
  if (pos <= 0) return 0;
  int f = getSum(fw, pos);
  int iff = getSum(fwint, pos);
  return f + iff * pos;
}
int getSegment(int from, int to) { return getPref(to) - getPref(from - 1); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  int dp[1001];
  memset(dp, 0, sizeof(dp));
  dp[1] = 0;
  for (int i = 2; i <= n + 1; i++) {
    if (p[i - 1] == i - 1) {
      dp[i] = dp[i - 1] + 2;
    } else {
      dp[i] = dp[i - 1] + 1 + dp[i - 1] - dp[p[i - 1]] + 1;
    }
    if (dp[i] < 0) dp[i] += modd;
    dp[i] %= modd;
  }
  printf("%d\n", dp[n + 1]);
  ;
  return 0;
  int pos = 1;
  int answ = 0;
  while (pos != n + 1) {
    int to = pos;
    {
      for (int i = 10; i >= 0; i--) {
        int tmp = to + (1 << i);
        if (tmp <= n + 1) {
          if (getSegment(to, tmp - 1) == (tmp - 1 - to + 1)) to = tmp;
        }
      }
    }
    answ += to - pos;
    if (answ >= modd) answ -= modd;
    setToZero(pos, to - 1);
    if (to == n + 1) break;
    addVal(fw, to, 1);
    answ += 1;
    if (answ >= modd) answ -= modd;
    pos = p[to];
  }
  printf("%d\n", answ);
}
