#include "partition.h"
#include <vector>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <iomanip>
#include <random>
#include <chrono>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

#define ll long long
#define pb push_back
#define fr first
#define sc second

const int N = 200005, N1 = 20;
const ll oo = 10000000000000000, MOD = 1000000007;

ll a[N];
pair<ll, int> p[N];
bool ok[N];

std::vector<int> solve(std::vector<int> A) {
	int n = A.size();
	vector<int> dis;
	vector<int> pat;
	ll limcan = 0;
	/*ll ans = 1, qan = 0;
	for (int i = 1; i <= 26; ++i) {
		cout << ans << " ";
		++qan;
		ans *= 2;
	}
	cout << qan << " " << ans << endl;*/
	for (int i = 1; i <= n; ++i) {
		a[i] = A[i - 1];
		ok[i] = 0;
		p[i].fr = a[i];
		p[i].sc = i - 1;
		limcan += a[i];
	}
	limcan /= 2;
	int target = n / 2;
	ll sum = 0;
	sort(p + 1, p + n + 1);
	vector<int> ynt, skizb, verj;
	ll mn = oo;
	int sfind = 0;
	vector<int> verc;
	//for (int i = n; i >= 1; --i) {
	//	smsuf[i] = smsuf[i + 1] + p[i].fr;
	//}
	for (int i = 1; i <= n; ++i) {
		sum += p[i].fr;
		int x2 = 0;
		ll sum1 = 0;
		/*int l = i, r = n;
		while (l <= r) {
			int mid = (l + r) / 2;
		}*/
		for (int j = n; j >= 1; --j) {
			sum1 += p[j].fr;
			if (sum1 + sum >= limcan) {
				x2 = j;
				break;
			}
		}
		if (ynt.size() + 1 + (n - x2 + 1) <= target) {
			ynt.pb(i);
			if ((target-(ynt.size() + (n - x2 + 1))) <= mn) {
				mn = (target - (ynt.size() + (n - x2 + 1)));
				verc = ynt;
				sfind = x2;
			}
		}
		else {
			if ((ynt.size()+1 + (n - x2 + 1)-target) < mn) {
				mn = (ynt.size() + 1 + (n - x2 + 1) - target);
				verc = ynt;
				sfind = x2;
				verc.pb(i);
			}
			sum -= p[i].fr;
		}
	}
	for (int num : verc) {
		ok[num] = 1;
		skizb.pb(p[num].sc);
	}
	for (int i = sfind; i <= n; ++i) {
		if (ok[i] != 1) {
			skizb.pb(p[i].sc);
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (ok[i] == 1 || i >= sfind) {
			continue;
		}
		else {
			verj.pb(p[i].sc);
		}
	}
	pat = skizb;
	for (int num : verj) {
		pat.pb(num);
	}
	return pat;
	/*vector<int> pat2;
	for (int i = 1; i < n / 2 + (n % 2); ++i) {
		pat2.pb(i - 1);
	}
	pat2.pb(n - 1);
	for (int j = n / 2 + (n % 2); j <= n - 1; ++j) {
		pat2.pb(j - 1);
	}*/
	/*if (pat.size() != pat2.size()) {
		cout << "HAGANQ" << endl;
		return pat;
	}
	for (int i = 0; i < pat.size(); ++i) {
		if (pat[i] != pat2[i]) {
			cout << "DS DS D" << i << " " << pat[i] << " " << pat2[i] << endl;
		}
	}*/
	/*vector<int> skizb, verj;
	for (int num : dis) {
		int sz = ind1[num].size();
		for (int i = 0; i < ind1[num].size(); ++i) {
			if (i < sz / 2) {
				skizb.pb(ind1[num][i]);
			}
			else {
				verj.pb(ind1[num][i]);
			}
		}
	}
	for (int num : skizb) {
		pat.pb(num - 1);
	}
	for (int num : verj) {
		pat.pb(num - 1);
	}
	return pat;*/
}
