//#include "infection.h"
//#include <utility>
#include "partition.h"
//#include <pch.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <ios>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>

#define FASTIO ios_base::sync_with_stdio(0);cin.tie(NULL);
#define vec vector<int>
#define pii pair<int,int>
#define vecl vector<long long>
#define sz size()
#define endl '\n'
#define pll pair<long,long>
#define ff first
#define ss second
#define pshb push_back
using ll = long long;


using namespace std;

vec solve(vec v) {
	int n = v.sz;
	vector<pii> x(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		x[i] = { v[i],i }; sum += v[i];
	}
	sort(x.begin(), x.end());
	vec ans(n);
	int mn = n;
	do {
		ll cur = 0;
		for (int i = 0; i < n; i++) {
			cur += x[i].ff;
			if (cur >= (sum + 1) / 2) {
				if (abs((i + 1) - (n - (i + 1))) < mn){
					mn = abs((i + 1) - (n - (i + 1)));
					for (int j = 0; j < n; j++)ans[j] = x[j].ss;
				}
			}
		}
	} while (next_permutation(x.begin(), x.end()));
	return ans;
}
