#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, char> p1, pair<long long int, char> p2) {
  return p1.first > p2.first;
}
long long int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int p[n + 1], a[n + 2], i, j;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
    a[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    a[i + 1] = (((2 * a[i] - a[p[i]]) % mod) + mod) % mod + 2;
    a[i + 1] = a[i + 1] % mod;
  }
  cout << a[n + 1] << "\n";
}
