#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second

vector<int> solve(vector<int> A) {
    vector <int> x;
    vector <int> y;
    ll a=0, b=0;
    for (int i=A.size()-1; i>-1; i--) {
        if (b<a) {
            y.push_back(i);
            b+=i;
        }
        else {
            x.push_back(i);
            a+=i;
        }
    }
    for (int i=0; i<y.size(); i++) {
        x.push_back(y[i]);
    }

    return x;
}