#include<iostream>
#include<vector>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define pb push_back

vector<int> solve(vector<int> a) {
    ll n = a.size();
    if (n == 1) {
        vector<int> v = {0};
        return v;
    }
    ll S = 0, s = 0;
    for (int i = 0; i < n; ++i) S += a[i];
    for (int i = 0; i < n/2; ++i)   s += a[i];
    if (s <= (S+1)/2) {
        for (int d = 0; d <= (n+1)/2-1; ++d) {
            s -= a[d];
            s += a[d+n/2];
            if (s >= (S+1)/2) {
                vector<int> v;
                for (int i = d+1; i <= d+n/2; ++i)  v.pb(i);
                for (int i = 0; i <= d; ++i)    v.pb(i);
                for (int i = d+n/2+1; i < n; ++i)   v.pb(i);
                return v;
            }
        }
    }
    reverse(a.begin(), a.end());
    auto v = solve(a);
    for (auto &x : v)    x = n-1-x;
    return v;
    s = S-s;
    for (int d = 0; d <= n/2-1; ++d) {
        s -= a[n-d-1];
        s += a[n-1-d-(n+1)/2];
        if (s >= (S+1)/2) {
            vector<int> v;
            for (int i = n-d-2; i >= n-1-d-(n+1)/2; --i)  v.pb(i);
            for (int i = 0; i < n-1-d-(n+1)/2; ++i)    v.pb(i);
            for (int i = n-d-1; i < n; ++i)   v.pb(i);
            return v;
        }
    }
}