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




vector<int> solve(vector<int> A) {
    sort(A.begin(),A.end());
    int N = A.size();
    int n = (N + 1) / 2;
    int num = 0;
    int sum = 1;
    for(int i = 0; i < n; ++i){
        num += A[i];
        sum += A[i];
    }
    for(int i = n; i < N; ++i){
        sum += A[i];
    }
    sum /= 2;
    sum -= num;
    int t = 0;
    while(sum > 0){
        sum += A[t];
        sum -= A[(N - 1) - t];
        t++;
    }
    vector<int> vec;
    for(int i = t; i < n; ++i){
        vec.push_back(i);
    }
    for(int i = N - t; i < N; ++i){
        vec.push_back(i);
    }
    for(int i = n; i < N - t; ++i){
        vec.push_back(i);
    }
    for(int i = 0; i < t; ++i){
        vec.push_back(i);
    }
    return vec;

}

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











