#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);

    int sum = 0;

    for(int i : vec)
        sum += 2 * 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";
//        }

        int localsum = 0, last = 0;

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

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

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

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

        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;
}
