#include <bits/stdc++.h>
using namespace std;
const int N = 1024;
const int mod = 1000000007;
int n, p[N];
void input() {
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> p[i], --p[i];
}
int mem[N][N];
int recur(int a, int b) {
  if (a >= b) return 0;
  if (mem[a][b] >= 0) return mem[a][b];
  return mem[a][b] = (recur(a, b - 1) + recur(p[b - 1], b - 1) + 2) % mod;
}
void solve() {
  memset(mem, -1, sizeof(mem));
  cout << recur(0, n) << endl;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  input();
  solve();
  return 0;
}
