#include "partition.h"
//#include "grader.cpp"

#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

using ll = long long;

std::vector<int> solve(std::vector<int> a) {
    int n = a.size();

    vector<array<int, 2>> b;

    for(int i = 0; i < n; i++) {
        b.push_back({a[i], i});
    }

    sort(b.begin(), b.end());

    ll S = accumulate(a.begin(), a.end(), 0ll);

    S = (S + 1) / 2;

    vector<int> ans1, ans2;

    for(int i = (int)b.size() - 1; i >= 0; i--) {
        if(S >= b[i][0]) {
            ans1.push_back(b[i][1]);
            S -= b[i][0];
        } else {
            ans2.push_back(b[i][1]);
        }
    }

    assert(S == 0);

    for(auto &x : ans2) ans1.push_back(x);

    return ans1;
}
