#include <bits/stdc++.h>
using namespace std;
std::vector<int> solve(std::vector<int> A) {
int n = A.size();
    vector<pair<int, int> > a(n);
    for(int i=0; i<n; i++)a[i] = {A[i], i};

    sort(A.begin(), A.end());

    int sum = 0;
    for(int &num : A)sum += num;
    int halfSum = (sum + 1) / 2;

    vector<int> v;
    for(int i=0; i<n; i++)v.push_back(i);
    int minNum = 1e9;

    do
    {
        int curSum = 0, curPos = 0;

        for(int i=0; i<n; i++)
        {
            curSum += a[i].first;
            if(curSum >= halfSum){curPos = i; break;}
        }

        int left = n - curPos - 1;

        if(minNum >= abs(curPos - left))
        {
            minNum = abs(curPos - left);

            for(int i=0; i<n; i++)v[i] = a[i].second;
        }
    }
    while(next_permutation(A.begin(), A.end()));

    return v;
}
