#include <bits/stdc++.h>
using namespace std;
long long power(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return res;
}
long long mod(long long a, long long b) { return (a % b + b) % b; }
long long powerm(long long base, long long exp, long long mod) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void tc() {
  long long n;
  cin >> n;
  const int mod = 1e9 + 7;
  vector<long long> arr(n, 0);
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  vector<long long> cnt(n, 2);
  for (long long i = 0; i < n; i++) {
    long long idx = arr[i];
    long long c = 0;
    for (long long j = idx; j < i; j++) {
      c += cnt[j];
      c = c % mod;
    }
    cnt[i] += c;
    cnt[i] %= mod;
    res = res + cnt[i];
    res = res % mod;
  }
  cout << res << '\n';
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    tc();
  }
  return 0;
}
