#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<int> solve(vector<int> A) {
    int n = A.size();
    vector<array<int, 2>> B;
    for (int i = 0; i < n; i++)
        B.push_back({A[i], i});
    sort(begin(B), end(B));
    int L = 0, R = 0;
    ll S = accumulate(begin(A), end(A), 0ll), cur = 0;
    while (R < n && cur + B[R][0] <= S / 2) {
        cur += B[R][0];
        R++;
    }
    reverse(begin(B), end(B));
    cur = 0;
    while (L < n && cur + B[L][0] <= S / 2) {
        cur += B[L][0];
        L++;
    }
    reverse(begin(B), end(B));
    reverse(begin(B), begin(B) + R);
    reverse(begin(B) + R, end(B));
    auto cnt = [&](int k) -> int {
        auto get = [&](int i) -> int {
            if (i < k) return B[i][0];
            if (i < k + n - R) return B[i - k + R][0];
            return B[i - n + R][0];
        };
        ll cur = 0;
        int T = 0;
        while (T < n && cur + get(T) <= S / 2) {
            cur += get(T);
            T++;
        }
        return T;
    };
    int v = n / 2;
    v = max(v, L);
    v = min(v, R);
    int l = 0, r = R + 1;
    while (r - l > 1) {
        int k = (l + r) / 2;
        if (cnt(k) <= v) l = k;
        else r = k;
    }
    int k = l;
    vector<int> C;
    for (int i = 0; i < k; i++)
        C.push_back(B[i][1]);
    for (int i = R; i < n; i++)
        C.push_back(B[i][1]);
    for (int i = k; i < R; i++)
        C.push_back(B[i][1]);
    reverse(begin(C), end(C));
    return C;
}




















#ifdef LOCAL

extern vector<int> solve(vector<int> A);
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t ;
    for (int test=1; test<=t; test++) {
        int n;
        cin >> n ;
        vector <int> a(n);
        for (int i=0; i<n; i++) {
            cin >> a[i] ;
        }

        for (auto ind : solve(a)) {
            cout << ind << " ";
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}

#endif // LOCAL
