#include <bits/stdc++.h>

using namespace std;

vector<int> solve(vector<int> a){
    int n = a.size();

    vector<pair<int,int>> b(n);
    for(int i=0;i<n;i++) b[i] = {a[i],i};
    sort(b.begin(),b.end(),greater<pair<int,int>>());

    int sum = 0;
    for(int i=0;i<n;i++) sum += a[i];
    
    int min_ = 1e9;
    int curr = 0;
    for(int i=0;i<n;i++){
        if (curr + b[i].first<=sum/2){
            curr += b[i].first;
            continue;
        }
        min_=min(min_,curr + b[i].first);
    }
    cout << min_ << "\n";

    vector<int> choose;
    vector<bool> taken(n,false);

    curr = 0;
    for(int i=0;i<n;i++){
        if (curr + b[i].first<=sum/2){
            curr += b[i].first;
            choose.push_back(b[i].second);
            taken[b[i].second]=true;
            continue;
        }
        if (curr + b[i].first==min_) break;
    }

    vector<int> res = choose;
    for(int i=0;i<n;i++){
        if(!taken[i]) res.push_back(i);
    }

    return res;
}
