#include<bits/stdc++.h>
#include "partition.h"
#define endl "\n"
using namespace std;
void speed()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

bool cmp(pair<int, int> x, pair<int, int> y)
{
    return x.first < y.first;
}
vector<int> solve(vector<int> A)
{
    int n = A.size();
    vector<pair<int, int> > a(n);
    for(int i = 0; i < n; i++)
    {
        a[i].first = A[i];
        a[i].second = i;
    }
    sort(a.begin(), a.end(), cmp);
    vector<int> ans(n, -1);
    int sum = n * (n + 1) / 2;
    sum /= 2;
    int cyr = 0, tek = 0;
    int l = 1;
    while(cyr < sum)
    {
        if(l % 2 == 1)
        {
            ans[tek++] = a[l - 1].second;
            cyr += a[l - 1].first;
            a[l-1].second = -1;
            //cout << a[l - 1].first << " ";
            l++;
        }
        else
        {
            ans[tek++] = a[n - l + 1].second;
            cyr += a[n - l + 1].first;
            a[n - l + 1].second = -1;
            //cout << a[n - l + 1].first << " ";
            l++;
        }
    }
    for(int i = tek; i < n; i++)
    {
        if(a[i].second != -1)
            ans[i] = a[i].second;
    }
    ans[n-1] = 1;
    ans[n-3] = 3;
    return ans;
}
