#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<int> p(n);
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> p[i];
    p[i]--;
  }
  vector<long long int> dist(n);
  dist[0] = 1;
  long long int cur = 3;
  for (int(x) = (1); (x) < (n); (x)++) {
    dist[x] = cur;
    if (p[x] == x)
      cur = cur + 2;
    else
      cur += cur - dist[p[x]] + 2;
    cur = (cur + M) % M;
  }
  cout << (cur - 1 + M) % M << '\n';
  return 0;
}
