#include <bits/stdc++.h>
using namespace std;
int inf = 1000000005;
long long int llinf = 2000000000000000005LL;
long long int mod = 1000000007;
long long int mod9 = 1000000009;
double pi = 3.1415926535897;
double eps = 1e-15;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1, true);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = 2; i < sq + 1; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
template <class T>
inline T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
inline vector<T> operator+(vector<T>& a, vector<T>& b) {
  assert(a.size() == b.size());
  int n = a.size();
  vector<T> c(n);
  for (int i = 0; i < n; i++) c[i] = a[i] + b[i];
  return c;
}
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
inline long long int bexp(long long int x, long long int n,
                          long long int m = mod) {
  long long int res = 1;
  x %= m;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
inline bool ispalin(string& str) {
  int n = str.length();
  for (int i = 0; i < n / 2; i++)
    if (str[i] != str[n - i - 1]) return false;
  return true;
}
inline void mapper(vector<int>& a, int idx = 0) {
  int cc = idx, n = a.size();
  map<int, vector<int> > mapp;
  for (int i = 0; i < n; i++) mapp[a[i]].push_back(i);
  for (auto& p : mapp) {
    for (int i : p.second) a[i] = cc;
    cc++;
  }
}
template <class T>
inline void ri(T& i) {
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (i = 0; c >= '0' && c <= '9'; c = getchar())
    i = (i << 3) + (i << 1) + (c - 48);
}
long long int Euclid(long long int a, long long int b, long long int& x,
                     long long int& y) {
  if (b == 0LL) {
    x = (a < 0LL ? -1LL : 1LL);
    y = 0LL;
    return a * x;
  }
  long long int q = a / b;
  long long int r = a % b;
  long long int d = Euclid(b, r, y, x);
  y -= q * x;
  return d;
}
int main() {
  int n;
  ri(n);
  vector<long long int> p(n + 1);
  for (int i = 1; i <= n; i++) ri(p[i]);
  vector<vector<long long int> > dp(n + 1, vector<long long int>(2, 0));
  for (int i = 1; i <= n; i++) {
    dp[i][1] = (dp[i - 1][0] + 1) % mod;
    dp[i][0] = (2 * dp[i][1] - dp[p[i]][1] + 1 + mod) % mod;
  }
  cout << dp[n][0] << "\n";
  return 0;
}
