#include<bits/stdc++.h>
using namespace std;
#define int long long
std::vector<int32_t> solve(std::vector<int32_t> A)
{
    vector<pair<int,int>> v;
    for(int i=0;i<A.size();i++)
        v.push_back({A[i], i});
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    int dif = 0;
    vector<pair<int,int>> pl,mi;
    for(int i=0;i<v.size();i++)
    {
        if(dif < 0)
        {
            dif += v[i].first;
            pl.push_back(v[i]);
        }
        else
        {
            dif -= v[i].first;
            mi.push_back(v[i]);
        }
    }

    
    vector<int32_t> sol;
    if(dif > 0)
    {
        for(auto [_,x]:pl)
            sol.push_back(x);
        for(auto [_,x]:mi)
            sol.push_back(x);
    }
    else
    {
        for(auto [_,x]:mi)
            sol.push_back(x);
        for(auto [_,x]:pl)
            sol.push_back(x);
    }
    return sol;
}
