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