#include "partition.h"
#include <bits/stdc++.h>
using namespace std;
long long s=0,sum=0,mn=1e18,a[2*1048576],n,p[30],used[2*1048576];
pair <long long,long long> x;
vector <int> ans;
bool m[30000111];
void print()
{
    vector <int> v;
    vector <long long> v1;
    v.clear();
    v1.clear();
    long long br=0,sum1=0,s1=0;
    for(long long i=0; i<n; i++)
    {
        if(p[i]==1)
        {
            sum1+=a[i];
            v.push_back(i);
            br++;
            if(sum1>=s/2+s%2)
            {
                if(mn>abs(br-(n-br)))
                {
                    mn=abs(br-(n-br));
                    ans=v;
                }
                return;
            }
        }
    }
}
void rek(long long pos)
{
    for(long long i=0; i<2; i++)
    {
        p[pos]=i;
        if(pos==n-1)print();
        else rek(pos+1);
    }
}
vector<int> solve(vector<int> A)
{
    mn=1e18;
    s=0;
    sum=0;
    n=A.size();
    ans.resize(n);
    int p1=0,p2=n-1;
    for(long long i=0; i<n; i++)
    {
        a[i]=A[i];
        s+=a[i];
        used[i]=0;
        p[i]=0;
        if(m[a[i]]==0)ans[p1++]=i;
        else ans[p2--]=i;
        m[a[i]]=!m[a[i]];
    }
    /*sort(a,a+n);
    rek(0);
    for(auto i:ans)used[i]=1;
    for(long long i=0; i<n; i++)
    {
        if(!used[i])ans.push_back(i);
    }*/
    return ans;
}
