#include <bits/stdc++.h>
int i, a[3000], n;
long long f[3000];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, 0, sizeof(f));
  f[1] = 0;
  for (i = 2; i <= n + 1; i++) {
    f[i] = (f[i - 1] * 2 + 2 - f[a[i - 1]]) % 1000000007;
  }
  if (f[n + 1] < 0) f[n + 1] += 1000000007;
  printf("%I64d\n", f[n + 1]);
  return 0;
}
