#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define fs first
#define sc second
using namespace std;

vector<int> solve(vector<int> a) {
    int n = a.size();
    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++) p.pb({a[i], i});
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    vector<int> vec1, vec2;
    vec1.pb(p[0].sc);
    for (int i = 2; i < n - 1; i+=2) {
        //cout << p[i].fs << " " << p[i].sc << " " << p[i - 1].fs << " " << p[i - 1].sc << endl;
        if (p[i].fs > p[i - 1].fs) vec2.pb(p[i - 1].sc), vec1.pb(p[i].sc);
        else vec2.pb(p[i].sc), vec1.pb(p[i - 1].sc);
        //for (auto u:vec1) cout << u << " ";
        //cout << endl;
    }
    if (n % 2 == 0) {
        //cout << "here" << endl;
        vec1.pb(p[n - 1].sc);
    }
    vector<int> ans;
    reverse(vec1.begin(), vec1.end());
    // for (int i = 0; i < vec1.size(); i++) ans.pb(vec1[i]), cout << vec1[i] << " ";
    // cout << endl;
    // for (int i = 0; i < vec2.size(); i++) ans.pb(vec2[i]), cout << vec2[i] << " ";
    // cout << endl;
    return ans;
}
// signed main() {
//     vector<int> a = {1, 2, 4, 5, 8, 5, 4, 3};
//     vector<int> res = solve(a);
//     for (auto u:res) cout << u << " ";
// }