#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include "partition.h"

#define debug(x) #x << " = " << x << '\n'
using ll = long long;

const ll INF = 1e18;

std::vector<int> solve(std::vector<int> a) {
    int n = (int) a.size();
    ll sum = +INF;

    int who = 0;

    for (int mask = 0; mask < (1 << n); mask++) {
        ll s = 0;
        for (int i = 0; i < n; i++) {
            if (mask >> i & 1) {
                s += a[i];
            } else {
                s -= a[i];
            }
        }
        if (s >= 0 && s < sum) {
            sum = s;
            who = mask;
        }
    }

    std::vector<int> answer1, answer2;
    ll s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
        if (who >> i & 1) {
            answer1.push_back(i);
            s1 += a[i];
        } else {
            answer2.push_back(i);
            s2 += a[i];
        }
    }

    assert(s1 >= s2);

    std::vector<int> answer = answer1;
    for (int x : answer2) {
        answer.push_back(x);
    }

    return answer;
}