#include "partition.h"
#include "bits/stdc++.h"
using namespace std;

#define ll long long
const ll INF=1e18;
vector<int>AC;

ll get(vector<int>a){
      ll sum=0;
      for(ll x:a) sum+=AC[x];
      ll cur=0,cnt=0;
      for(int i=0;i<AC.size();i++){
            cur+=AC[a[i]];
            cnt++;
            if(cur>=sum/2+(sum&1)) break;
      }
      int n=(int)AC.size();
      ll c1=cnt;
      ll c2=n-cnt;
      return abs(c1-c2);
}

vector<int>solve(vector<int>A)
{
      AC=A;
      pair<ll,vector<int>>mn={INF,{}};
      vector<int>p;
      for(int i=0;i<A.size();i++) p.push_back(i);
      do{
            mn=min(mn,{get(p),p});
      }while(next_permutation(p.begin(),p.end()));
      return mn.second;
}
