#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
long long s=0,sum=0,mn=1e18,a[2*1048576],n,p[30],used[2*1048576];
pair <int,int> x;
vector <int> ans;
void print()
{
    vector <int> v;
    v.clear();
    long long br=0,sum1=0,s1=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]==1)
        {
            s1=sum1;
            sum1+=a[i];
            v.push_back(i);
            br++;
        }
    }
    if(s1<s/2+s%2&&sum1>=s/2+s%2)
    {
        if(mn>abs(br-(n-br)))
        {
            mn=abs(br-(n-br));
            ans=v;
        }
    }
}
void rek(int pos)
{
    for(int i=0;i<2;i++)
    {
        p[pos]=i;
        if(pos==n-1)print();
        else rek(pos+1);
    }
}
vector<int> solve(vector<int> A)
{
    mn=1e18;
    s=0;
    sum=0;
    n=A.size();
    for(int i=0;i<n;i++)
    {
        a[i]=A[i];
        s+=a[i];
        used[i]=0;
    }
    sort(a,a+n);
    rek(0);
    for(auto i:ans)used[i]=1;
    for(int i=0;i<n;i++)
    {
        if(!used[i])ans.push_back(i);
    }
    return ans;
}
