#include<bits/stdc++.h>

#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())

using namespace std;


vector < int > slv (vector < int > a) {
    int n = sz(a);
    vector < int > p(n);
    ll S = 0;
    for (int i = 0; i < n; ++i) S += a[i];
    iota(all(p), 0);
    sort(all(p), [&](int li, int ri) {
        return a[li] < a[ri];
    });
    int ans = n + 1;
    ll si = 0;
    S = (S + 1) / 2;
//    int opt = 0;
    int l, r;
    for (int i = -1; i < n; ++i) {
        if (i >= 0) si += a[p[i]];
        ll x = si;
        int j = n - 1;
        while (x < S) {
            x += a[p[j--]];
        }
        if (ans > i + 1 + n - 1 - j) {
            ans = min(ans, i + 1 + n - 1 - j);
            l = i, r = j + 1;
        }
    }
//    cout << ans << " " << l << " " << r << "\n";
    int c = 0;
    for (int i = 0; i <= l; ++i)
        a[c++] = p[i];
    for (int i = r; i < n; ++i)
        a[c++] = p[i];
    for (int i = l + 1; i < min(n, r); ++i)
        a[c++] = p[i];
    return a;
}


signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;
    vector < int > a;
    cin >> test;
    while (test--) {
        int n;
        cin >> n;
        a.resize(n);
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        a = slv(a);
        for (int x : a)
            cout << x << " ";
        cout << "\n";
    }
}
