#include <bits/stdc++.h>   using namespace std;   int k[1005], n, i, j;   long long kx[1005];   int main() {     cin >> n;     for (i = 1; i <= n; i++) cin >> k[i];     kx[1] = 2;     for (i = 2; i <= n; i++) {       if (k[i] == i)         kx[i] = 2;       else {         for (j = k[i]; j < i; j++) kx[i] = (kx[i] + kx[j]) % 1000000007;         kx[i] = (kx[i] + 2) % 1000000007;       }     }     long long ans = 0;     for (i = 1; i <= n; i++) ans = (ans + kx[i]) % 1000000007;     cout << ans;     return 0;   }   