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