#include "bits/stdc++.h"

using namespace std;

// #define int long long

vector<int> solve(vector<int> a) {
    int n = (int) a.size();
    long long sm = 0;
    if (n == 1) {
        return {0};
    }
    vector<pair<long long, int>> vec;
    map<long long, vector<int>> mp;
    for (int i = 0; i < n; i++) {
        // vec.push_back({a[i], i});
        mp[a[i]].push_back(i);
        sm += a[i];
    }
    for (auto i : mp) {
        for (auto j : i.second)
            vec.push_back({i.first, j});
    }

    int ans = 1e9;
    vector<int> vans;
    for (int cs = 0; cs < 2; cs++) {
        int del = (n >> 1) + cs;
        deque<int> dq;
        long long sm1 = 0;
        int ind = n - 1;
        for (int i = 0; i < del; i++) {
            dq.push_back(vec[i].second);
            sm1 += vec[i].first;
        }
        while (sm1 < (sm & 1 ? ((sm >> 1) + 1) : (sm >> 1)) && ind >= del) {
            sm1 -= a[dq.front()];
            dq.pop_front();
            dq.push_back(vec[ind].second);
            sm1 += vec[ind].first;
            ind--;
        }
        if (sm1 >= (sm & 1 ? (sm >> 1) + 1 : (sm >> 1)) && ans > abs((n - del) - del)) {
            ans = abs((n - del) - del);
            map<long long, vector<int>> mp1;
            for (auto i : dq)
                mp1[a[i]].push_back(i);
            for (auto i : mp) {
                for (auto j : i.second)
                    vans.push_back(j);
            }
        }
    }
    vector<bool> used(n + 10);
    for (auto i : vans)
        used[i] = 1;
    for (int i = 0; i < n; i++)
        if (!used[i])
            vans.push_back(i);

    return vans;
}

// int32_t main() {

//     ios::sync_with_stdio(false);
//     cin.tie(nullptr); cout.tie(nullptr);

//     int T = 1;
//     // cin >> T;
//     while (T--) {

//     }

//     return 0;
// }