#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
std::vector<int> solve(std::vector<int> A) {
    int n = A.size();
    int l = n / 2, r = l;
    if (n & 1) {
        r++;
    }
    vector<int> ans;
    long long s = 0;
    for (auto i : A) s += i;
    pair<int, int> f[n];
    for (int i = 0; i < n; ++i) {
        f[i] = {A[i], i};
    }
    if (!is_sorted(A.begin(), A.end())) {
        sort(f + 0, f + n, [&](pair<int, int>& i, pair<int, int>& j) {
             return i.first < j.first;
        });
    }
    long long pref[n];
    bool can[n];
    long long ss = 0;
    for (int i = 0; i < n; ++i) {
        pref[i] = 0;
        if (i - 1 >= 0) {
            pref[i] = pref[i - 1];
        }
        pref[i] += f[i].first;
        ss += f[i].first;
        if (2 * ss < s || 2 * (ss - f[i].first) < s) can[i] = true;
        else can[i] = false;
    }
    while (true) {
        int k;
        if (abs(l - n + l) < abs(r - n + r)) k = l, l--;
        else k = r, r++;
        long long sum = pref[k - 1];
        if (2 * sum < s) {
            int l = 1, r = min(k, n - k);
            while (true) {
                if (l >= r) break;
                int mid = (l + r) >> 1;
                if (2 * (sum - pref[mid - 1] + s - pref[n - mid - 1]) >= s) r = mid;
                else l = mid + 1;
            }
            vector<bool> used(n);
            for (int i = l; i < k; ++i) ans.push_back(f[i].second);
            for (int i = n - l; i < n; ++i) ans.push_back(f[i].second);
            for (auto &i : ans) used[i] = true;
            for (int i = 0; i < n; ++i) {
                if (!used[i]) ans.push_back(i);
            }
            return ans;
        } else {
            if (can[k - 1]) {
                for (auto [val, idx] : f) ans.push_back(idx);
                return ans;
            }
        }
    }
    return ans;
}