#include <iostream>
#include <vector>
using namespace std;
vector<int> solve(vector<int> a) {
	long long n = a.size();
	long long sum = 0, target = n * (n + 1) / 4;
	vector<bool> used(n, false);
	for (int i = n - 1; i >= 0; i--) {
		if (target - sum >= a[i]) {
			used[i] = true;
			sum += a[i];
		}
		else {
			if (target != sum) {
				used[target - sum - 1] = true;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << used[i] << " ";
	}
	vector <int> final;
	for (int i = 0; i < n; i++) {
		if (used[i]) final.push_back(i);
	}
	for (int i = 0; i < n; i++) {
		if (!used[i]) final.push_back(i);
	}
	return final;
}