#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<random>
#include<ctime>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,sse4,popcnt")

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;

const int N = 2e5 + 2, inf = 1e9 + 100;
const ll llinf = 1e18 + 1000;

vector<int> solve(vector<int> a) {
	int n = a.size(), mx = 0, indmx = -1;
	ll s = 0;
	for (int i = 0; i < n; ++i) {
		s += a[i];
		if (a[i] > mx) {
			mx = a[i];
			indmx = i;
		}
	}
	vector<pair<int, int>> al, ar;
	for (int i = 0; i < n; ++i) {
		if (i == indmx) continue;
		if (al.size() < ar.size()) {
			al.push_back({ a[i], i });
		}
		else {
			ar.push_back({ a[i], i });
		}
	}
	ll sl = 0;
	for (int i = 0; i < al.size(); ++i) {
		if (al[i].first > ar[i].first) {
			swap(al[i], ar[i]);
		}
		sl += al[i].first;
	}
	for (int i = 0; 1; ++i) {
		if ((sl + mx) * 2 >= s) break;
		sl -= al[i].first;
		sl += ar[i].first;
		swap(al[i], ar[i]);
	}
	vector<int> ans;
	for (auto i : al) ans.push_back(i.second);
	ans.push_back(indmx);
	for (auto i : ar) ans.push_back(i.second);
	return ans;
}

void solve() {
	vector<int> ans = solve({ 5, 6, 6, 3, 1, 1, 4, 4, 3 });
	for (auto i : ans) cout << i << ' ';
}

//signed main() {
//	ios_base::sync_with_stdio(0);
//	cin.tie(0);
//	int tt = 1;
//	//cin >> tt;
//	while (tt--) {
//		solve();
//		cout << '\n';
//		cout.flush();
//	}
//	return 0;
//}