func_code_string: #include <bits/stdc++.h>   using namespace std;   int countBits(long long mask) {     int res = 0;     while (mask) mask &= (mask - 1), ++res;     return res;   }   string toString(long long n) {     stringstream ss;     ss << n;     return ss.str();   }   long long toNumber(string s) {     stringstream ss;     long long n;     ss << s;     ss >> n;     return n;   }   int n, p[1001], dp[1001];   int main() {     while (cin >> n) {       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i) cin >> p[i];       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i) {         dp[i] = 1;         if (i != p[i])           for (int j = (int)(p[i]), _m = (int)(i); j < _m; ++j)             dp[i] = (dp[i] + dp[j] + 1) % 1000000007;       }       int res = 0;       for (int i = (int)(1), _m = (int)(n + 1); i < _m; ++i)         res = (res + dp[i] + 1) % 1000000007;       cout << res << endl;     }   }   