#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long dp[n + 1], sums[n + 1], MOD = 1e9 + 7, ans = 2;
  sums[0] = 0;
  dp[1] = sums[1] = 2;
  for (int i = 2; i <= n; i++) {
    dp[i] = 2;
    if (i != a[i]) {
      dp[i] =
          ((dp[i] + dp[a[i]]) % MOD + (sums[i - 1] - sums[a[i]] + MOD) % MOD) %
          MOD;
    }
    sums[i] = (dp[i] + sums[i - 1]) % MOD;
    ans = (ans + dp[i]) % MOD;
  }
  cout << ans;
  return 0;
}
