#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e7;
vector<int> ans;
vector<int> p;
vector<int> c;
int n;
int S = 0;
vector<int> curr;
int min_bal = 1e9 + 10;
void check(){
    int sum = 0;
    for(int el: curr){
        sum += c[el];
    }
    if(sum < S / 2) return;
    int sz = curr.size();
    int last = n - sz;
    int ball = abs(last - sz);
    if(ball < min_bal){
        p = curr;
    }
}
void rec(int idx){
    if(idx == n){
        check();
    }
    rec(idx + 1);
    curr.push_back(idx);
    rec(idx + 1);
    curr.pop_back();
}
bool vis[MAXN];
vector<int> solve(vector<int> a){
    n = a.size();
    c = a;
    for(int el: a) S += el;
    rec(0);
    for(int idx: p){
        vis[idx] = true;
        ans.push_back(idx);
    }
    for(int i = 0; i < n; i++){
        if(vis[i]) continue;
        ans.push_back(i);
    }
    return ans;
}
