#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int vis[1001][1001];
long long dp[1001];
long long ans = 0, n;
const int MOD = 1e9 + 7;
long long solve(int idx, int t, long long k) {
  if (idx == n) return ans = k;
  vis[t][idx]++;
  if (idx == t && vis[t][t] == 2) return dp[t] = (k + 1) % MOD;
  if (dp[idx] != -1) {
    for (int i = 0; i < n; i++) {
      vis[t][i] += vis[idx][i];
    }
    vis[t][idx]--;
    return solve(idx + 1, t, k + dp[idx]);
  }
  if (vis[t][idx] % 2 == 0) return solve(idx + 1, t, k + 1);
  return solve(arr[idx], t, k + 1);
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  for (int i = 0; i < n; i++) solve(i, i, 0);
  if (ans) cout << ans;
  int x = 0;
  while (x != n) {
    ans += dp[x];
    ans %= MOD;
    x++;
  }
  cout << ans;
  return 0;
}
