func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   int dp[maxn][maxn];   int n, ans;   int tim[maxn];   int dfs(int i, int j) {     if (dp[i][j]) return dp[i][j];     int ti = tim[i], tj = tim[j], tk = tim[j + 1];     if (j == n + 1) return dp[i][j] = ti;     if (j == n) return dp[i][j] = max(ti, tj);     int choseij = max(ti, tj) + dfs(j + 1, j + 2),         choseik = max(ti, tk) + dfs(j, j + 2),         chosejk = max(tj, tk) + dfs(i, j + 2);     dp[i][j] = min(min(choseij, choseik), chosejk);     return dp[i][j];   }   void print_ans(int i, int j) {     int ti = tim[i], tj = tim[j], tk = tim[j + 1];     if (j == n + 1) {       cout << i << endl;       return;     }     if (j == n) {       cout << i <<     << j << endl;       return;     }     int choseij = max(ti, tj) + dp[j + 1][j + 2],         choseik = max(ti, tk) + dp[j][j + 2],         chosejk = max(tj, tk) + dp[i][j + 2];     if (dp[i][j] == choseij) {       cout << i <<     << j << endl;       print_ans(j + 1, j + 2);       return;     }     if (dp[i][j] == choseik) {       cout << i <<     << j + 1 << endl;       print_ans(j, j + 2);       return;     }     if (dp[i][j] == chosejk) {       cout << j <<     << j + 1 << endl;       print_ans(i, j + 2);       return;     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> tim[i];     ans = dfs(1, 2);     cout << ans << endl;     print_ans(1, 2);     return 0;   }   