// brute force
#include "partition.h"
#include<bits/stdc++.h>
#deine int long long
using namespace std;

std::vector<int> solve(std::vector<int> a){
    vector<pair<int, int>>v;
    int n = a.size();
    for(int i = 0; i < n; i++){
        v.push_back({a[i], i});
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    vector<int>d, m;
    int sum_d = 0, sum_m = 0;
    for(int i = 0; i < v.size(); i++){
        if(i%2 == 0){
            d.push_back(v[i].second);
            sum_d += v[i].first;
        }
        if(i%2 == 1){
            m.push_back(v[i].second);
            sum_m += v[i].first;
        }
    }
    if(sum_d > sum_m){
        swap(d, m);
    }
    vector<int>ans;
    reverse(m.begin(), m.end());
    //reverse(d.begin(), d.end());
    for(int i = 0; i < m.size(); i++)ans.push_back(m[i]);
    for(int i = 0; i < d.size(); i++)ans.push_back(d[i]);
    return ans;
}
/**
extern vector<int> solve(vector<int> A);
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;
}
*/
