func_code_string: #include <bits/stdc++.h>   using namespace std;   int vis[200005][3], n;   long long dp[200005][3], a[200005];   long long dfs(int x, int s) {     if (dp[x][s]) return dp[x][s];     if (vis[x][s]) return -1;     vis[x][s] = 1;     int k;     if (s)       k = x + a[x];     else       k = x - a[x];     if (k <= 0 || k > n)       dp[x][s] += a[x];     else {       dp[x][s] = dfs(k, s ^ 1);       if (dp[x][s] != -1) dp[x][s] += a[x];     }     return dp[x][s];   }   int main() {     while (scanf( %d , &n) != EOF) {       memset(vis, 0, sizeof(vis));       memset(dp, 0, sizeof(dp));       for (int i = 2; i <= n; i++) scanf( %I64d , &a[i]);       for (int i = 2; i <= n; i++) dfs(i, 0);       for (int i = 1; i < n; i++) {         if (dp[i + 1][0] == -1)           printf( -1 n );         else           printf( %I64d n , i + dp[i + 1][0]);       }     }     return 0;   }   