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

const int MAXN = 2e6+7;
int n, a[MAXN];
bool found[MAXN];

vector<int> solve(vector<int> A)
{
    n = A.size();
    fill(found, found+n+1, false);
    int s = 0;
    for(int i = 0; i < n; i++)
    {
        a[i+1] = A[i];
        s += a[i+1];
    }
    sort(a+1, a+n+1);
    s = s/2+(s%2);
    int sum = 0, nn = n/2+(n%2);
    vector<int> ff, ss;
    for(int i = 1; i <= nn; i++)
    {
        sum += a[i];
        ff.push_back(i-1);
        found[ff.back()] = true;
    }
    for(int i = n; i >= nn; i--)
    {
        if(sum >= s) break;
        sum += a[i]-a[ff.back()+1];
        found[ff.back()] = false;
        ff.pop_back();
        ss.push_back(i-1);
        found[ss.back()] = true;
    }
    vector<int> ans = ff;
    int sz = ss.size();
    for(int i = 0; i < sz; i++)
    {
        ans.push_back(ss[i]);
    }
    for(int i = 0; i < n; i++)
    {
        if(!found[i]) ans.push_back(i);
    }
    return ans;
}
