#include <bits/stdc++.h>

using namespace std;

#define int ll

#define fi first
#define se second

#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

const int NMAX = 2e6+5;

int n, S;
vector<signed> a, v, best;
bool ap[NMAX];
int ans;

void backtrack(int cnt = 0, int s = 0) {
   if (2ll * s >= S) {
      if (abs(n - cnt - cnt) < ans) {
         ans = abs(n - cnt - cnt);
         best = v;
         assert(sz(v) == cnt);
         for (int i = 0; i < n; i++) {
            if (!ap[i]) {
               best.push_back(i);
            }
         }
         assert(sz(best) == n);
      }
      return;
   }

   for (int i = 0; i < n; i++) {
      if (!ap[i]) {
         ap[i] = true;
         v.push_back(i);
         backtrack(cnt + 1, s + a[i]);
         if (ans <= 1) break;
         v.pop_back();
         ap[i] = false;
      }
   }
}

vector<signed> solve(vector<signed> A) {
   if (n > 20) return {};
   n = sz(A);
   a = A;
   fill(ap, ap + n + 1, false);
   v.clear();
   best.clear();

   ans = 2 * n;
   S = 0;
   for (int i = 0; i < n; i++) {
      S += a[i];
   }

   backtrack();

#ifdef LOCAL
   cout << "ans " << ans << endl;
#endif

   if (sz(best) != n) {
      for (int i = 0; i < n; i++) {
         best[i] = i;
      }
      return best;
   }
   
   return best;
}

#undef int

#ifdef LOCAL
namespace grader {
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] ;
        }

        auto ans = solve(a);
        for (auto ind : ans) {
            cout << a[ind] << " ";
        }
        cout << endl;

        sort(all(ans));
        assert(sz(ans) == n);

        for (int i = 0; i < n; i++) {
           assert(i == ans[i]);
        }
    }
    cout << endl ;
    return 0;
}
};
signed main() {
   freopen("input.txt", "r", stdin);
   grader::main();
   return 0;
}
#endif
