#include <bits/stdc++.h>
long long timestamp[1005][2];
bool vis[1005];
int p[1005];
int n;
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(timestamp, 0, sizeof(timestamp));
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", p + i);
    }
    timestamp[1][0] = 1;
    vis[1] = 1;
    int x = 1, s = 0;
    long long t = 1;
    while (1) {
      if (x == n + 1) {
        break;
      }
      if (s == 0) {
        if (timestamp[p[x]][vis[p[x]]] == 0) {
          x = p[x];
          s = vis[p[x]];
          t++;
          t %= 1000000007;
          timestamp[x][s] = t;
        } else {
          timestamp[x][vis[x]] =
              (t + 1 + t - timestamp[p[x]][vis[p[x]]] + 1000000007) %
              1000000007;
          t = timestamp[x][vis[x]];
          s = vis[x];
        }
        vis[x] = !vis[x];
      } else {
        x++;
        s = vis[x];
        t++;
        t %= 1000000007;
        timestamp[x][s] = t;
        vis[x] = !vis[x];
      }
    }
    printf("%I64d\n", t - 1);
  }
}
