#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector < int > solve(vector < int > a) {
    int n = (int)a.size();

    ll s = 0;
    for (auto x : a) s += x;

    ll crr = 0;
    int mn = 0, mx = 0;

    for (int i = 0; i < n; i++) {
        mx++, crr += a[i];
        if (crr * 2ll >= s) break;
    }

    crr = 0;
    for (int i = n - 1; i >= 0; i--) {
        mn++, crr += a[i];
        if (crr * 2ll >= s) break;
    }

    int opt = (n + 1) / 2;
    opt = max(mn, min(mx, opt));

    if (opt == n) {
        vector < int > res(n);
        for (int i = 0; i < n; i++) res[i] = i;
        return res;
    }

    crr = 0;
    vector < ll > p(n);
    for (int i = 0; i < n; i++) { crr += a[i]; p[i] = crr; }

    int lg = 0;

    for (int l = 0; l < opt; l++) {
        int r = opt - l - 1;
        ll base = 0;
        if (l) base += p[l - 1];
        if (r) base += (s - (n - r - 1 >= 0 ? p[n - r - 1] : 0ll));

        while (lg < n && (base + a[lg]) * 2ll < s) lg++;
        lg = max(lg, l);
        if (lg >= n) break;

        if (lg < n - r) {
            ll val = a[lg] + base;
            ll val1 = val;
            if (r) val1 -= a[n - 1];
            else val1 -= a[lg];

            if (val * 2ll >= s && val1 * 2ll < s) {
                vector < int > res;
                for (int i = 0; i < l; i++) res.push_back(i);
                res.push_back(lg);
                for (int i = n - r; i < n; i++) res.push_back(i);
                for (int i = l; i < lg; i++) res.push_back(i);
                for (int i = lg + 1; i < n - r; i++) res.push_back(i);
                return res;
            }
        }
    }

    exit(1);
}
