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