#include <bits/stdc++.h>
#include "partition.h"
using namespace std;
using ll = long long;
using pll = pair <ll,ll>;
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define pb push_back
vector <int> solve(vector <int> A){
	ll n = A.size();
	ll S = 0;
	vector <ll> a(n);
	map <ll,vector <ll>> mp;
	set <ll> s;
	bool b1 = true;
	bool b2 = true;
	for (ll i = 0;i < n;i++){
		a[i] = A[i];
		mp[a[i]].pb(i);
		s.insert(a[i]);
		S += a[i];
		if (a[i] != (1 << i))b2 = false;
	}
	for (auto x: s)if (mp[x].size() & 1)b1 = false;
	if (b1){
		vector <ll> ans1,ans2;
		for (auto x: s){
			for (ll i = 0;2 * i < mp[x].size();i++){
				ans1.pb(mp[x][i]);
			}
			for (ll i = mp[x].size() / 2;i < mp[x].size();i++){
				ans2.pb(mp[x][i]);
			}
		}
		vector <ll> ans;
		for (ll i = 0;i < n;i++){
			if (i < n / 2){
				ans.pb(ans1[i]);
			}
			else {
				ans.pb(ans2[i - n / 2]);
			}
		}
		vector <int> anss;
		for (ll i = 0;i < n;i++){
			int z = int(ans[i]);
			anss.pb(z);
		}
		return anss;
	}
	if (b2){
		vector <int> ans;
		for (int i = 0;i < n;i++)ans.pb(i);
		return ans;
	}
}