#include "partition.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> solve(std::vector<int> a) {
    #define int long long
    int n = a.size(), sum = accumulate(a.begin(), a.end(), 0ll);
    int best = n;
    vector<int> ans(n);
    vector<int> v(n);
    iota(v.begin(), v.end(), 0);
    do {
        int cur = 0;
        for (int i = 0; i < n; i++) {
            cur += a[v[i]];
            if (cur >= sum / 2) {
                if (abs((i + 1) - (n - i - 1)) < best) {
                    best = abs((i + 1) - (n - i - 1));
                    ans = v;
                    break;
                }
            }
        }
    } while (next_permutation(v.begin(), v.end()));
    return ans;
}