#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

std::vector<int> solve(std::vector<int> A) {
    vector<pii> packs(A.size());
    ll sum = 0;
    int N = A.size();
    for (int i = 0; i < A.size(); i++) {
        packs[i] = {A[i], i};
        sum += A[i];
    }
    //sort(packs.begin(), packs.end());
    vector<int> ans(N, 2);
    int num_packs = (N+1)/2;
    int st = (N + 2)/4;
    int last_idx = packs[st].second;
    for (int i = 0; i < num_packs; i++) {
        int idx = packs[i + st].second;
        ans[idx] = 1;
        last_idx = idx;
    }
    vector<int> divide;
    for (int i = 0; i < N; i++) {
        if (i != last_idx && ans[i] == 1) divide.push_back(i);
    }    
    divide.push_back(last_idx);
    for (int i = 0; i < N; i++) {
        if (ans[i] == 2) divide.push_back(i);
    }
    return divide;
}

// 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;
// }