#include "partition.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const ll N=2e6;
vector <int> ans,anss,nw,nww;
std::vector<int> solve(std::vector<int> a) {
    
    ll n=a.size();
    ans.clear();
    anss.clear();int sum=0;
    for (int i=0; i<n; i++){
    	ans.pb(i); sum+=a[i];
	}
	
	ll pw=(1<<n); int mxx,z,s,dif,mx=n+1;
	for (ll j=1; j<=pw; j++){
		z=j;
		nw.clear(); nww.clear();
		mxx=0; s=0;
		int indd=-1;
		for (int i=0; i<a.size(); i++){
			if (((1<<i)&z)==0){
				nww.pb(i); continue; }
			nw.pb(i); 
			mxx=max(mxx,a[i]); if (mxx==a[i]) indd=i; s+=a[i];
		}
		if (s<(sum+1)/2) continue;
		if ((s-mxx)>=(sum+1)/2) continue;
		dif=nw.size()-(n-nw.size());
		if (dif<0) dif*=(-1);
	//	cout<<dif<<endl;
		if (dif>=mx) continue; mx=dif;
		int k=-1;
		for (int i=0; i<nw.size(); i++){
			if (indd==nw[i]) continue;
			k++;
			ans[k]=nw[i];
		}
		ans[nw.size()-1]=indd;
		for (int i=nw.size(); i<n; i++){
			ans[i]=nww[i-nw.size()];
		}
		
	}
//	cout<<mx<<endl;
	return ans;
	
    
}
