#include <bits/stdc++.h>
using namespace std;
vector<int> solve(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 half = (sum + 1) / 2;

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

    do
    {
        int curSum = 0;
        int curPos = 0;

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

        int person1 = curPos + 1;
        int person2 = n - person1;

        if(minNum > abs(person1 - person2))
        {
            minNum = abs(person1 - person2);
            for(int i=0; i<n; i++)rez[i] = a[i].second;
        }
    }
    while(next_permutation(a.begin(), a.end()));

    return rez;
}
