#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) (x).begin(),(x).end()

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
// #define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int, int>;
using tii = tuple<int, int, int>;

std::vector<int> solve(std::vector<int> A) {
	if(sz(A) == 1) {
		return {0};
	}
	int N = sz(A);
	
	ll totalsum = accumulate(all(A), 0ll);
	ll sum;
	int r, l;
	
	sum = 0;
	r = sz(A), l = 0;
	while(sum * 2 < totalsum) sum += A[--r];
 	if((N - r) > N / 2) {
		sum = totalsum - sum;
		l = r;
		r = sz(A);
		while(sum * 2 < totalsum) sum += A[l++];
		
		while(l + (N - r) < N / 2) {
			sum -= A[--l];
			while(sum * 2 < totalsum) sum += A[--r];
		}
		r = max(l, r);
		
		vector<int> rez;
		rez.reserve(N);
		for(int i = 0; i < l; i++) rez.emplace_back(i);
		for(int i = N - 1; i >= r; i--) rez.emplace_back(i);
		if(sz(rez) != N / 2)
			rez.insert(begin(rez) + N / 2 - 1, l);
		else
			l--;
		for(int i = l + 1; i < r; i++) rez.emplace_back(i);
		return rez;
	}
	else {
		
		while(l + (N - r) < N / 2) {
			sum -= A[r++];
			while(sum * 2 < totalsum) sum += A[l++];
		}
		l = min(l, r - 1);
		
		vector<int> rez;
		rez.reserve(N);
		for(int i = N - 1; i >= r; i--) rez.emplace_back(i);
		for(int i = 0; i < l; i++) rez.emplace_back(i);
		if(sz(rez) != N / 2)
			rez.insert(begin(rez) + N / 2 - 1, r - 1);
		else
			r++;
		for(int i = l; i < r - 1; i++) rez.emplace_back(i);
		return rez;
	}
}
