#include <bits/stdc++.h>
int main() {
  long long int n, a[10005] = {0}, p[1005], i;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &p[i]);
  for (i = 1; i <= n; i++)
    a[i + 1] = (a[i] * 2 + 2 - a[p[i]] + 1000000007) % 1000000007;
  printf("%lld\n", a[n + 1]);
  return 0;
}
