func_code_string: #include <bits/stdc++.h>   char putnb[20];   using namespace std;   const long long mod = 1e9 + 7;   const long long mod2 = 1999999973;   const int infs = 1e8;   const long long inf = 1e18;   const int N = 200000;   long long A[N + 5];   long long dp[N + 5][2];   bool vis[N + 5][2];   bool solved[N + 5][2];   long long n;   long long solve(long long pos, int state) {     if (pos <= 0 || pos > n) return 0;     if (vis[pos][state] && !solved[pos][state]) return -1;     vis[pos][state] = true;     if (pos == 1) {       if (state) return 0 - inf;       return -1;     }     if (solved[pos][state]) return dp[pos][state];     if (!state) {       long long v1 = solve(pos + A[pos], 1);       if (v1 == -1)         dp[pos][state] = -1;       else         dp[pos][state] = v1 + A[pos];     } else {       long long v2 = solve(pos - A[pos], 0);       if (v2 == -1)         dp[pos][state] = -1;       else         dp[pos][state] = v2 + A[pos];     }     solved[pos][state] = true;     return dp[pos][state];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n;     for (int i = 2; i <= n; ++i) cin >> A[i];     for (int i = 1; i <= n - 1; ++i) {       long long res = solve(1 + i, 1);       if (res == -1)         cout << res <<   n ;       else if (res >= 0)         cout << res + i <<   n ;       else if (res < 0)         cout << (res + inf + 2 * i) <<   n ;     }     return 0;   }   