#include <bits/stdc++.h>
using namespace std;
long long dp[1 << 20];
long long a[1 << 20];
long long n;
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  dp[1] = 2;
  for (long long i = 2; i <= n; i++) {
    dp[i] = ((2 * dp[i - 1] + 2 - dp[a[i - 1] - 1]) % 1000000007 + 1000000007) %
            1000000007;
  }
  cout << dp[n];
}
