func_code_string: #include <bits/stdc++.h>   using namespace std;   long long arr[200005];   long long n;   map<long long, long long> ans;   bool debug = false;   long long rec(long long node) {     if (debug) cout <<  entering   << node << endl;     if (node == 1) return 1000000000000;     if (node <= 0 || node > n) return 0;     if (ans.count(node) && ans[node] == -1000000000000)       return ans[node] = 1000000000000;     if (ans.count(node)) {       if (debug) cout <<  already computed for   << node << endl;       return ans[node];     }     ans[node] = -1000000000000;     long long val = 0;     long long n1 = node + arr[node];     val += arr[node];     if (n1 <= 0 || n1 > n) return ans[node] = val;     long long n2 = n1 - arr[n1];     val += arr[n1];     return ans[node] = val + rec(n2);   }   int main() {     scanf( %lld , &n);     for (__typeof(n - 1) i = 0; i < n - 1; i++) scanf( %lld , &arr[i + 2]);     long long k;     for (__typeof(n) i = 2; i <= n; i++) {       long long val = i - 1;       long long nex = i - arr[i];       val += arr[i];       k = rec(nex) + val;       if (k >= 1000000000000)         cout << -1 << endl;       else         cout << k << endl;     }     return 0;   }   