#include <bits/stdc++.h>

using namespace std;

const int N = (int)3e5 + 9;

long long ok(int x, vector < int > &a, vector < int > &c, long long &S) {
    vector < int > b;

    for (int i = x; i < (int)a.size(); i++) b.push_back(a[i]);
    for (int i = 0; i < x; i++) b.push_back(a[i]);

    long long su = 0, ind = 0;
    for (int i = 0; su < (S + 1) / 2; i++) su += c[b[i]], ind++;

    return (abs((int)a.size() - 2 * ind));
}

vector < int > solve(vector < int > c) {
    vector < int > a((int)c.size()); for (int i = 0; i < (int)c.size(); i++) a[i] = i;


    auto comp = [&](int i, int j) {
        return c[i] < c[j];
    };

    sort(a.begin(), a.end(), comp);
    for (int i = 0; i < (int)c.size(); i++) a.push_back(a[i]);

    long long mx = (int)1e18, n = (int)c.size(), S = accumulate(c.begin(), c.end(), 0ll), e = 0, pf[n + 1];


    long long su = 0, ind = 0;

    for (int q = 0; q <= n / 2 + 1; q++) {
        while (su < (S + 1) / 2) su += c[a[ind]], ind++;
        int ee = abs(n - 2 * (ind - q));

        if (mx >= ee) {
            mx = ee;
            e = q;
        } else break;

        su -= c[a[q]];
    }


    vector < int > ans;
    ans.clear();
    for (int i = e; i < n; i++) ans.push_back(a[i]);
    for (int i = 0; i < e; i++) ans.push_back(a[i]);

    return ans;
}