func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     long a[n + 1], b[n + 1];     for (i = 0; i < n; i++) cin >> a[i];     a[n] = 1;     b[0] = 1;     for (i = 1; i <= n; i++) {       b[i] = (2 * b[i - 1] - b[a[i - 1] - 1] + 2) % 1000000007;       if (b[i] < 0) b[i] += 1000000007;     }     cout << (b[n] - 1);     return 0;   }   