func_code_string: #include <bits/stdc++.h>   using namespace std;   struct triplet {     int first, second, third;   } per[1005];   pair<int, int> pr[1005 / 2][1005], s[1005 / 2];   int n, a[1005], dp[1005], k, l, ind[1005 / 2][1005], indice, minim = 1 << 30,                                                                pas;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n + 2; i++) dp[i] = 1 << 30;     pas = 1;     per[1] = {1, 2, 3};     dp[1] = 0;     while (pas + 2 <= n) {       ++k;       for (int i = 1; i <= pas; i++) {         if (dp[pas + 1] > dp[i] + max(a[per[i].first], a[per[i].third])) {           dp[pas + 1] = dp[i] + max(a[per[i].first], a[per[i].third]);           pr[k][pas + 1] = {per[i].first, per[i].third};           ind[k][pas + 1] = i;         }         if (dp[pas + 2] > dp[i] + max(a[per[i].first], a[per[i].second])) {           dp[pas + 2] = dp[i] + max(a[per[i].first], a[per[i].second]);           pr[k][pas + 2] = {per[i].first, per[i].second};           ind[k][pas + 2] = i;         }         dp[i] = dp[i] + max(a[per[i].second], a[per[i].third]);         pr[k][i] = {per[i].second, per[i].third};         ind[k][i] = i;         per[i] = {i, pas + 3, pas + 4};       }       per[pas + 1] = {pas + 1, pas + 3, pas + 4};       per[pas + 2] = {pas + 2, pas + 3, pas + 4};       pas += 2;     }     l = 1;     for (int i = 1; i <= pas; i++)       if (dp[i] + max(a[per[i].first], a[per[i].second]) < minim) {         minim = dp[i] + max(a[per[i].first], a[per[i].second]);         s[l] = {per[i].first, per[i].second};         indice = i;       }     for (int i = k; i >= 1; i--) {       s[++l] = pr[i][indice];       indice = ind[i][indice];     }     cout << minim <<   n ;     for (int i = l; i > 1; i--) cout << s[i].first <<     << s[i].second <<   n ;     if (n % 2 == 0)       cout << s[1].first <<     << s[1].second;     else       cout << s[1].first;     return 0;   }   