#include "bits/stdc++.h"
#include "partition.h"
#include "grader.cpp"
using namespace std;


#define int long long
#define N 500005

const int inf = INT_MAX;

int a[N], n, ans, S = 0, b[N];
vector <int> c;

void solv(int x,int sm,int cnt) {
    if(sm * 2 >= S) {
        int l = cnt;
        int r = n - cnt;
        if(ans > abs(r - l)) {
            ans = abs(r - l);
            for(int i= 1; i <= n; i++) {
                c[i] = b[i];
            }
        }
        return;
    }
    if(x == n) {
        return;
    }
    b[x] = 1;
    solv(x + 1, sm + a[x], cnt + 1);
    b[x] = 0;
    solv(x + 1, sm, cnt);
}

vector<int> solve(vector<int> A) {
    S = 0;
    c.resize(n + 1, 0);
    ans = inf;
    for(int i = 0; i < n; i++) {
        S += A[i];
        c[i] = i;
    }
    solv(0, 0, 0);
    return c;

}
