#include "partition.h"
#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define nl '\n'

#define long int64_t

using namespace std;

vector <int> solve(vector <int> a) {
    int n = a.size();
    long sum = 0;
    for (int i = 0; i < n; ++i)
        sum += a[i];
    int lst = 0, msk = 0;
    long s = 0, ans = 0;
    for (int k = 1; k < (1 << n); ++k) {
        int nw = k ^ (k >> 1), i = __builtin_ctz(lst ^ nw);
        if (nw & (1 << i))
            s += a[i];
        else
            s -= a[i];
        if (s * 2 <= sum && s > ans) {
            ans = s;
            msk = nw;
        }
        lst = nw;
    }
    vector <int> v;
    for (int i = 0; i < n; ++i)
        if ((msk & (1 << i)) == 0)
            v.pb(i);
    for (int i = 0; i < n; ++i)
        if (msk & (1 << i))
            v.pb(i);
    return v;
}

#undef long
