#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int dp[1111], p[1111];
int rec(int n) {
  if (dp[n] != -1) return dp[n];
  if (n == 1) return 1;
  return dp[n] =
             (((rec(n - 1) - rec(p[n - 1])) % mod + rec(n - 1) % mod) % mod +
              2) %
             mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  memset(dp, -1, sizeof dp);
  cout << (rec(n + 1) + mod - 1) % mod << "\n";
  return 0;
}
