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