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

int n ;
std :: vector < int > sol ;
int mn = 2000005 ;
bool ok = 0 ;

void rec ( int nr , long long suma_act , int ind , long long suma_fin , std :: vector < int > a , std :: vector < int > pana_acm )
{
    if ( ok == 0 ){
    if ( suma_act > suma_fin )
    {
        int dif = abs ( nr - ( n - nr ) ) ;
        if ( dif < mn )
        {
            mn = dif ;
            sol = pana_acm ;
        }
        if ( mn <= 1 )
            ok = 1 ;
    }
    else if ( ind < n )
    {
        rec ( nr , suma_act , ind + 1 , suma_fin , a , pana_acm ) ;
        pana_acm.push_back(ind) ;
        rec ( nr + 1 , suma_act + a[ind] , ind + 1 , suma_fin , a , pana_acm ) ;
        pana_acm.pop_back() ;
    }
    }
}

std::vector<int> solve(std::vector<int> V)
{
    sol.resize(0) ;
    long long sum = 0 ;
    for ( auto it : V )
        sum += it ;
    n = V.size() ;
    sum /= 2 ;
    ok = 0 ;
    mn = 2000005 ;
    rec ( 0 , 0 , 0 , sum , V , {} ) ;
    bool sel[n+1] = {0} ;
    for ( auto it : sol )
        sel[it] = 1 ;
    for ( int i = 0 ; i < n ; i ++ )
        if ( sel[i] == 0 )
            sol.push_back(i) ;
    return sol ;
}