#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int verify(vector<int> A, vector<int> perm, ll sum)
{
    int k=0, n=A.size();
    ll acc = 0;
    while (k<n && acc<((float)sum/2.0))
    {
        acc+=A[perm[k++]];
    }
    return abs(n-2*k);
}

vector<int> brute(vector<int> A)
{
    int n = A.size();
    vector<int> B;
    for (int i = 0; i < n; i++)
    {
        B.push_back(i);
    }
    ll sum = accumulate(A.begin(), A.end(), 0ll);
    vector<int> best;
    int mini = n;
    do
    {
        int k = verify(A, B, sum);
        if (k< mini)
        {
            mini = k;
            best = B;
        }
    } while (next_permutation(B.begin(), B.end()));
    return best;
}

vector<int> solve(vector<int> A)
{
    int n = A.size();
    vector<pair<ll,ll>> B;
    for (int i = 0; i < n; i++)
    {
        B.push_back({A[i], i});
    }
    sort(B.begin(), B.end());
    vector<ll> prefix(n+1, 0), suffix(n+1, 0);
    for (int i = 0; i < n; i++)
    {
        prefix[i+1] = prefix[i]+B[i].first;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        suffix[i] = suffix[i+1]+B[i].first;
    }
    ll sum = accumulate(A.begin(), A.end(), 0ll);
    for (int k = n/2; k<n; k++)
    {
        for (int i = 0; i < k; i++)
        {
            if (prefix[i]+suffix[n-k+i] >= sum/2 && prefix[i]+suffix[n-k+i]-B.back().first < sum/2)
            {
                vector<int> ans;
                for (int j = 1; j <= i; j++)
                {
                    ans.push_back(B[j-1].second);
                }
                for (int j = n-k+i; j < n; j++)
                {
                    ans.push_back(B[j].second);
                }
                for (int j = i; j < n-k+i; j++)
                {
                    ans.push_back(B[j].second);
                }
                return ans;
            }
            else if (prefix[i]+suffix[n-k+i] < sum/2)
            {
                break;
            }
        }
    }
    return vector<int>();
}

#ifdef DEBUG
void stress()
{
    int q = 5000;
    int seed = 14;
    srand(seed);
    int n = 7;
    while (q--)
    {
        vector<int> A(n);
        for (auto &a : A) a = 1<<(rand()%26);
        ll sum = accumulate(A.begin(), A.end(), 0ll);
        auto ans1 = brute(A);
        auto ans2 = solve(A);
        if (verify(A, ans1, sum) < verify(A, ans2, sum))
        {
            for (auto a : A) cout << a << ' ';
            cout << endl;
            for (auto a : ans1) cout << a << ' ';
            cout << endl;
            for (auto a : ans2) cout << a << ' ';
            cout << endl;
            cout << endl;
        }
    }
}

int main () {
    // stress();
    // return 0;
    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
