func_code_string: #include <bits/stdc++.h>   using namespace std;   int N;   long long dp[2 * 100000 + 10][2], arr[2 * 100000 + 10];   long long Solve(int, bool);   int main() {     scanf( %d , &N);     dp[0][0] = dp[0][1] = dp[1][0] = dp[1][1] = -2;     for (int i = 2; i <= N; i++) {       scanf( %I64d , &arr[i]);       dp[i][0] = dp[i][1] = -2;     }     for (int i = 2; i <= N; i++) Solve(i, 0), Solve(i, 1);     for (int i = 1; i < N; i++)       dp[1 + i][0] != -1 ? printf( %I64d n , dp[1 + i][0] + i) : printf( -1 n );     return 0;   }   long long Solve(int ind, bool f) {     if (ind <= 0 || ind > N) return 0;     if (dp[ind][f] == -3) return -1;     if (dp[ind][f] != -2) return dp[ind][f];     dp[ind][f] = -3;     long long ret, a;     if (f)       a = Solve(ind + arr[ind], 0);     else       a = Solve(ind - arr[ind], 1);     if (a == -1)       ret = -1;     else       ret = a + (long long)arr[ind];     return dp[ind][f] = ret;   }   