#include "partition.h"
// peta podzadacha?
#include<algorithm>
#include<iostream>
using namespace std;
std::vector<int> solve(std::vector<int> A) {
    vector<int> ans;
    int n = A.size();
    long long sum = 0;
    for(int a : A) sum += (long long)a;
    if(sum % 2 == 1) sum = (sum + 1) / 2;
    vector<pair<long long, int>> B, ANS;
    for(int i = 0; i < n; ++i){
        B.push_back({A[i], i});
    }
    int best_diff = n + 2;
    while(next_permutation(B.begin(), B.end())){
        long long s = 0;
        for(int i = 0; i < n; ++i){
            s += B[i].first;
            if(s >= sum){
                int zhena1 = i + 1;
                int zhena2 = n - zhena1;
                int diff = abs(zhena1 - zhena2);
                if(diff < best_diff){
                    best_diff = diff;
                    ANS = B;
                }
                break;
            }
        }
        if(best_diff == 0) break;
    }
    for(int i = 0; i < n; ++i){
        ans.push_back(ANS[i].second);
    }
    return ans;
}
