#include <bits/stdc++.h>
using namespace std;
vector<int> solve(vector<int> A){
    vector<int> perm;
    int n = A.size();
    int sum = 0;
    for(auto x : A){
        sum+=x;
    }
    for(int i=0; i<n; i++){
        perm.push_back(i);
    }
    vector<int> ans;
    int bestcnt = -1;
    do{
        int s = 0;
        int cnt = 0;
        for(int i=0; i<n; i++){
            s+=A[perm[i]];
            cnt++;
            if(s>=(sum+1)/2){
                break;
            }
        }
        int ot = n-cnt;
        if((bestcnt==-1)|| abs(cnt-ot)<bestcnt){
            bestcnt = abs(cnt-ot);
            ans = perm;
        }
        /*for(auto x : perm){
            cout << x << " ";
        }
        cout << endl;
        cout << abs(cnt-ot) << endl;*/
    }while(next_permutation(perm.begin(),perm.end()));
    //cout << bestcnt << endl;
    return ans;
}
/*int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t ;
    for (int test=1; test<=t; test++) {
        int n;
        cin >> n ;
        vector <int> a(n);
        for (int i=0; i<n; i++) {
            cin >> a[i] ;
        }

        for (auto ind : solve(a)) {
            cout << ind << " ";
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}*/
