#include <bits/stdc++.h>
#include "partition.h"
using namespace std;



vector<int> solve(vector<int> A) {
    vector <int> ans;
    vector <pair <int, int>> v;
    int sum = 0, sumA = 0;
    for (int i = 0; i < A.size(); i ++) {
        v.push_back({A[i], i});
    }

    sort (v.begin(), v.end());

    if (v.size() % 2 == 0) {
        for (int i = 0; i < v.size() / 2; i += 2) {
            ans.push_back(v[v.size() - i - 1].second);
            ans.push_back(v[i].second);
        }
        for (int i = 1; i < v.size() / 2; i += 2) {
            ans.push_back(v[i].second);
            ans.push_back(v[v.size() - i - 1].second);
        }
    } else {
        ans.push_back(v[0].second);
        for (int i = 1; i <= v.size() / 2; i += 2) {
            ans.push_back(v[i].second);
            ans.push_back(v[v.size() - i].second);
        }
        for (int i = 2; i <= v.size() / 2; i += 2) {
            ans.push_back(v[i].second);
            ans.push_back(v[v.size() - i].second);
        }
    }

    return ans;
}