#include "partition.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define ll long long
using namespace std;
const int N=2e5+5;

vector<int> solve(vector<int> v)
{
    int n=v.size();
    ll tot=0;
    for(auto x:v) tot+=x;
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int a, int b) {return v[a]<v[b];});
    set<int> in;
    ll ss=0;
    for(int i=0;i<(n-1)/2;++i)
    {
        ss+=v[ord[i]];
        in.insert(i);
    }
    if(n%2==1)
    {
        int mid=n/2-1;
        for(int i=0;i<n/2&&ss<(tot+1)/2;++i)
        {
            ss-=v[ord[mid-i]];
            in.erase(mid-i);
            ss+=v[ord[mid+i+2]];
            in.insert(mid+i+2);
        }
        if(ss<(tot+1)/2) in.insert(mid+1);
        vector<int> sol;
        for(auto x:in) sol.pb(x);
        for(int i=n-1;i>=0;--i) if(in.find(i)==in.end()) sol.pb(ord[i]);
        return sol;
    }
    else
    {
        int mid=n/2-1;
        for(int i=0;i<n/2&&ss<(tot+1)/2;++i)
        {
            ss-=v[ord[mid-i]];
            in.erase(mid-i);
            ss+=v[ord[mid+i+1]];
            in.insert(mid+i+1);
        }
        vector<int> sol;
        for(auto x:in) sol.pb(ord[x]);
        for(int i=n-1;i>=0;--i) if(in.find(i)==in.end()) sol.pb(ord[i]);
        return sol;
    }
}

