#include "partition.h"
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
const int N = 2e6 + 67;

#define all(X) (X).begin(), (X).end()
#define ff first
#define ss second

bool used[N];
pair<int, int>a[N];

std::vector<int> solve(std::vector<int> A) 
{
	int n = A.size();
	for (int i = 0; i < n; i++)
		a[i + 1] = { A[i], i };
	sort(all(A));
	int l = 1, r = n;
	vector<int>answ;
	while (l <= r)
	{
		answ.push_back(a[r].ss);
		int sm = 0;
		while (l <= r - 1 && sm < a[r].ff)
		{
			answ.push_back(a[l].ss);
			sm += a[l].ff, l++;
		}
		r--;
	}
	return answ;
}
