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