# include <iostream>
# include <algorithm>
# include <vector>
using namespace std;
# include "partition.h"
//# include "grader.cpp"

const long long INF=1e18;
const int MAX=1e6+11;

int n;
long long a[MAX];

std::vector<int> solve(std::vector<int> A)
{
    n=A.size();
    long long S=0;
    for(int i=0;i<n;i++)
    {
        a[i]=A[i];
        S+=a[i];
    }

    vector<int> ans(n),perm;
    for(int i=0;i<n;i++) ans[i]=i;
    perm=ans;
    long long diff=INF;
    do
    {
        long long curr=0,cnt0=0,cnt1=0;
        for(int i=0;i<n;i++)
        {
            curr+=a[perm[i]];
            cnt0++;
            if(curr*2>=S)
            {
                break;
            }
        }
        cnt1=n-cnt0;

        if(abs(cnt1-cnt0)<diff)
        {
            diff=abs(cnt1-cnt0);
            ans=perm;
        }

    }while(next_permutation(perm.begin(),perm.end()));

    return ans;
}

