#include <bits/stdc++.h>
#include "partition.h"

using namespace std;
const int nmax = 2e6;
vector <int> sol, vv, rez;
struct ura
{
    int ord, val;
}v[nmax + 1];
bool cmp(ura a, ura b)
{
    if(a.val < b.val)
        return true;
    if(a.val > b.val)
        return false;
    return true;
}
std::vector<int> solve(std::vector<int> A)
{
    int n = A.size(), i, st = 0, dr;
    long long a = 0, b = 0;
    sol.resize(n);
    dr = n - 1;
    for(i = 0; i < n; i++)
    {
        v[i].ord = i;
        v[i].val = A[i];
    }
    sort(v, v + n, cmp);
    for(i = n - 1; i >= 0; i--)
    {
        if(a <= b)
        {
            a += v[i].val;
            sol[st++] = v[i].ord;
        }
        else
        {
            b += v[i].val;
            sol[dr--] = v[i].ord;
        }
    }
    if(a < b)
    {
        for(st = 0, dr = n - 1; st < dr; st++, dr--)
            swap(sol[st], sol[dr]);
    }
    return sol;
}