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