#include <bits/stdc++.h>
using namespace std;
int p[1005];
long long dp[1005];
const long long mod = 1000000007;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  dp[1] = 0;
  dp[2] = 2;
  for (int i = 3; i <= n + 1; i++) {
    dp[i] = (dp[i - 1] * 2 + mod - dp[p[i - 1]] + 2);
    dp[i] %= mod;
  }
  printf("%I64d\n", dp[n + 1]);
}
