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