#include "partition.h"
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define F first
#define S second
#define pii pair<int, int>
#define ins insert

bool check(vector<int> x, vector<int> res, vector<int> A, int sum){
    int i1 = -1, sum1 = 0;
    while((double)sum1 < (double)sum / 2){
        i1++;
        sum1 += A[x[i1]];
    }
    int i2 = -1, sum2 = 0;
    while((double)sum2 < (double)sum / 2){
        i2++;
        sum2 += A[res[i2]];
    }
    int sz = x.size();
    if(abs(sz - i1) < abs(sz - i2)) return true;
    else return false;
}

vector<int> solve(vector<int> A) {
    int n = A.size();
    int sum = 0;
    vector<int> res;
    rep(i, 0, n - 1){res.pb(i); sum += A[i];}
    for(int mask = 0; mask < (1 << n); mask++){
        vector<int> a, b;
        for(int i = 0; i < n; i++){
            if(mask & (1 << i)) a.pb(i);
            else b.pb(i);
        }
        vector<int> x = a;
        for(int i : b) x.pb(i);
        if(check(x, res, A, sum)) res = x;
    }
    return res;
}
