func_code_string: #include <bits/stdc++.h>   const double eps = 1e-7, PI = 3.1415926;   const int N = 2e5 + 10;   using namespace std;   long long n, q, m, k, x, y, a[N], mx = -1, mem[N][3], vis[N][3], mn = 1e9, sum,                                     t;   char c[N];   string s, s1, s2;   map<int, int> mp;   vector<int> vec;   long long dp(long long i, int cur) {     if (i <= 0 || i > n) return 0;     if (vis[i][cur] == x) return -1e17;     if (mem[i][cur] != -1) return mem[i][cur];     vis[i][cur] = x;     long long p1 = 0, p2 = 0;     if (cur == 0)       p1 += a[i] + dp(i + a[i], cur ^ 1);     else       p1 += a[i] + dp(i - a[i], cur ^ 1);     return mem[i][cur] = p1;   }   int main() {     cin >> n;     memset(mem, -1, sizeof mem);     for (int i = 2; i <= n; i++) cin >> a[i];     for (int i = 1; i < n; i++) {       a[1] = i;       mem[1][0] = -1;       x++;       long long ans = dp(1, 0);       if (ans >= 0)         cout << ans << endl;       else         cout << -1 << endl;     }     return 0;   }   