#include "bits/stdc++.h"
#include "partition.h"
// #include "grader.cpp"

using namespace std;

#define SZ(s) (int)s.size()
#define ll long long
#define ff first
#define ss second

vector<int> solve(vector<int> a) {
    int n = SZ(a);
    ll s = 0;
    vector <pair <int, int>> v;
    for(int i = 0; i < n; i++) {
        s += a[i];
        v.push_back({a[i], i});
    }
    sort(v.begin(), v.end());
    ll sm = 0;
    vector <int> p;
    vector <int> vis(n, 0);
    for(int i = 0; i < n; i++) {
        for(int i = n-1; i >= 0; i--) {
            if(!vis[i] and (sm + v[i].ff) * 2 <= s) {
                vis[i] = true;
                sm += v[i].ff;
                p.push_back(v[i].ss);
            }
        }
    }
    for(int i = 0; i < n; i++) {
        if(!vis[i]) p.push_back(v[i].ss);
    }
    reverse(p.begin(), p.end());
    return p;
}
