func_code_string: #include <bits/stdc++.h>   using namespace std;   const unsigned int tb[32] = {13, 0,  27, 1,  28, 18, 23, 2,  29, 21, 19,                                12, 24, 9,  14, 3,  30, 26, 17, 22, 20, 11,                                8,  13, 25, 16, 10, 7,  15, 6,  5,  4};   int n, m, tot;   priority_queue<long long, std::vector<long long>, std::greater<long long> > q1,       q2, q3;   void calc(priority_queue<long long, std::vector<long long>,                            std::greater<long long> >& q,             long long& ans) {     while (q.size() > 1) {       if (q.size() >= 3) {         long long x = q.top();         q.pop();         long long y = q.top();         q.pop();         long long z = q.top();         q.pop();         ans += x + y + z;         q.push(x + y + z);       } else {         ans += q.top();         q.pop();         ans += q.top();       }     }   }   int main() {     int T = 1;     for (int ci = 1; ci <= T; ++ci) {       scanf( %d , &n);       for (int i = 0; i < n; ++i) {         int x;         scanf( %d , &x);         q1.push(x);         q2.push(x);         q3.push(x);       }       long long ans1 = 0, ans2 = 0, ans3 = 0;       if (q1.size() >= 2) {         int x = q1.top();         q1.pop();         int y = q1.top();         q1.pop();         ans1 = x + y;         q1.push(x + y);       }       if (q2.size() >= 4) {         int x = q2.top();         q2.pop();         int y = q2.top();         q2.pop();         ans2 = x + y;         int u = q2.top();         q2.pop();         int v = q2.top();         q2.pop();         ans2 += u + v;         q2.push(x + y);         q2.push(u + v);       }       calc(q1, ans1);       calc(q2, ans2);       calc(q3, ans3);       long long ans = min(min(ans1, ans2), ans3);       cout << ans << endl;     }     return 0;   }   