#include <bits/stdc++.h>
using namespace std;
vector <int> ans;
long long a[8];
long long minc, s;
int n;
void check(vector <int> p)
{
    long long sum = 0;
    long long h = s/2;
    if(s%2)h++;
    int i = 0;
    while(sum < h)
    {
        sum += a[p[i]];
        i++;
    }
    if(abs(n-i-i) < minc)
    {
        ans = p;
        minc = abs(n-i-i);
    }
}
std::vector<int> solve(std::vector<int> A)
{
    n = A.size();
    s = 0;
    minc = 1e9;
    vector <int> p;
    for(int i = 0; i < n; i++)
        p.push_back(i);
    for(int i = 0; i < n; i++)
    {
        a[i] = A[i];
        s += a[i];
    }
    ans.clear();
    vector <int> last;
    for(int i = n-1; i >= 0; i--)
        last.push_back(i);
    while(p != last)
    {
        check(p);
        next_permutation(p.begin(), p.end());
    }
    check(last);
    return ans;
}
