#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> solve6sau2(vector<int> vec) {

}
vector<int> solve5(vector<int> vec) {
    vector<int> seven(n);
    vector<int> ans(n);

    long long sum = 0;

    for(int i : vec)
        sum += 2ll * i;

    for(int i = 0; i < n; i++)
        seven[i] = i;

    int prod = 1;

    for(int i = 2; i <= n; i++)
        prod *= i;

    int minn = 10;

    for(int i = 0; i < prod; i++) {
//        if(i < 10) {
//            for(int dick : seven)
//                cout << dick << " ";
//
//            cout << "\n";
//        }

        long long localsum = 0;
        int last = 0;

        for(int j = 0; j < n; j++) {
            localsum += 2ll * vec[seven[j]];

            if(localsum >= sum / 2) {
                last = j;
                break;
            }
        }

        int dif = abs((last + 1) - (n - 1 - last));

//        cout << i << " " << dif << "\n";

        if(dif < minn) {
            ans = seven;
            minn = dif;
        }

        next_permutation(seven.begin(), seven.end());
    }

    return ans;
}
std::vector<int> solve(std::vector<int> A) {
    n = A.size();
    vector<int> ans(n);
    ans = solve5(A);
    return ans;
}
