# include <iostream>
using namespace std;
# include "partition.h"
//# include "grader.cpp"

const int MAX=(1<<25);

int n;
int a[MAX];
long long sum[MAX];
int mx[MAX];

std::vector<int> solve(std::vector<int> A)
{
    n=A.size();
    for(int i=0;i<n;i++) a[i]=A[i];

    sum[0]=0;
    mx[0]=0;
    for(int mask=1;mask<(1<<n);mask++)
    {
        int j=31-__builtin_clz(mask);
        sum[mask]=sum[mask^(1<<j)]+a[j];
        mx[mask]=max(mx[mask^(1<<j)],a[j]);
    }

    long long S=sum[(1<<n)-1];
    int bst=0,diff=1e9;
    for(int mask=1;mask<(1<<n);mask++)
    {
        if(sum[mask]*2<S) continue;
        int m=mx[mask];
        if((sum[mask]-m)*2>=S) continue;
        int cnt=__builtin_popcount(mask),cnt2=n-cnt;
        if(abs(cnt2-cnt)<diff)
        {
            diff=abs(cnt2-cnt);
            bst=mask;
        }
    }

    int m=-1;
    for(int i=0;i<n;i++)
    {
        if((bst&(1<<i))==0) continue;
        if(m==-1 or a[m]<a[i]) m=i;
    }

    vector<int> ans;
    for(int i=0;i<n;i++) if((bst&(1<<i))>0 and i!=m) ans.push_back(i);
    ans.push_back(m);
    for(int i=0;i<n;i++) if((bst&(1<<i))==0) ans.push_back(i);
    return ans;
}
