func_code_string: #include <bits/stdc++.h>   using namespace std;   static const double PI = acos(-1.0);   static const double EPS = 1e-9;   long long n;   long long a[200010];   long long dp[200010][2];   inline bool border(long long x) { return 0 <= x && x < n; }   long long dfs(long long x, long long step) {     if (dp[x][step] != -1) return dp[x][step];     dp[x][step] = -2;     if (step == 0) {       if (!border(x + a[x])) {         return dp[x][step] = a[x];       } else {         long long y = dfs(x + a[x], 1);         if (y == -2)           return dp[x][step] = -2;         else           return dp[x][step] = y + a[x];       }     } else if (step == 1) {       if (!border(x - a[x])) {         return dp[x][step] = a[x];       } else {         long long y = dfs(x - a[x], 0);         if (y == -2)           return dp[x][step] = -2;         else           return dp[x][step] = y + a[x];       }     }   }   int main() {     int i, j;     cin >> n;     for (i = 1; i < n; ++i) cin >> a[i];     for (i = 0; i < n; ++i)       for (j = 0; j < 2; ++j) dp[i][j] = -1;     for (i = 1; i < n; ++i)       for (j = 0; j < 2; ++j) dfs(i, j);     for (i = 1; i < n; ++i) {       if (dp[i][1] == -2)         puts( -1 );       else         printf( %I64d n , dp[i][1] + i);     }     return 0;   }   