#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
std::vector<int> solve(std::vector<int> A) {
    int n = A.size();
    bool dp[(1 << n)]; memset(dp, false, sizeof dp);
    int sum[(1 << n)]; memset(sum, 0, sizeof sum);
    int from[(1 << n)]; memset(from, 0, sizeof from);
    dp[0] = true;
    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) sum[mask] += A[i];
        }
    }
    int s = 0;
    for (auto i : A) s += i;
    int delta_min = 1e9;
    int tmask = -1;
    for (int mask = 0; mask < (1 << n); ++mask) {
        //cout << sum[mask] << endl;
        if (2 * sum[mask] >= s && dp[mask]) {
            int f1 = __builtin_popcount(mask), f2 = n - f1;
           /// cout << f1 << " " << f2 << endl;
            if (delta_min > abs(f1 - f2)) {
                delta_min = abs(f1 - f2);
                tmask = mask;
            }
            continue;
        }
        if (2 * sum[mask] >= s) continue;
        for (int i = 0; i < n; ++i) {
            if (!(mask & (1 << i))) {
                dp[mask | (1 << i)] = true;
                from[mask | (1 << i)] = i;
            }
        }
    }
    vector<int> ans;
    vector<bool> used(n);
    while (tmask != 0) {
        used[from[tmask]] = true;
        ans.push_back(from[tmask]);
        tmask ^= (1 << from[tmask]);
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < n; ++i) {
        if (!used[i]) ans.push_back(i);
    }
    return ans;
}