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

using namespace std;

vector<int> solve(vector<int> a) {
    int n = (int)a.size();
    long long S = 0;
    for (int i : a) S += i;

    vector<int> ind(n);
    iota(ind.begin(), ind.end(), 0);

    int len = n / 2;
    if (n & 1) {
        long long now = 0;
        for (int i = 0; i <= n / 2; i++) {
            now += a[ind[i]];
        }
        if (now * 2 < S) len++;
        else return ind;
    }
    long long sum = 0;
    vector<bool> left(n);
    for (int i = 0; i < len; i++) sum += a[ind[i]], left[ind[i]] = 1;
    for (int i = 0; i < len; i++) {
        if (sum * 2 >= S) break;
        left[ind[i]] = 0;
        left[ind[n - i - 1]] = 1;
        sum -= a[ind[i]];
        sum += a[ind[n - i - 1]];
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) if (left[ind[i]]) ans.push_back(ind[i]);
    for (int i = 0; i < n; i++) if (!left[ind[i]]) ans.push_back(ind[i]);
    return ans;
}
