#include <bits/stdc++.h>
#include <vector>

using namespace std;

vector<int> ind;
vector<int> perm;

std::vector<int> solve(std::vector<int> v) {
    int i, n, sumA, sumB, diff, s, cateA, cateB, mini;
    n = v.size();
    s = 0;
    ind.clear();
    for( i = 0; i < n; i++ ) {
        ind.push_back( i );
        s += v[i];
    }
    mini = INT_MAX;
    do {
        i = sumA = sumB = cateA = cateB = 0;
        while( i < n && sumA < s / 2 )
            sumA += ind[i++], cateA++;
        while( i < n )
            sumB += ind[i++], cateB++;

        diff = abs( cateA - cateB );
        if( diff < mini ) {
            mini = diff;
            perm = ind;
        }
    } while( next_permutation( ind.begin(), ind.end() ) );
    return perm;
}
