#include "partition.h"
#include <bits/stdc++.h>

#define int long long

using namespace std;

using pii = pair<int, int>;

vector<signed> solve(vector<signed> A) {
    int n = A.size();
    int S = accumulate(A.begin(), A.end(), 0ll);
    int s = 0, pl = n / 2, sl = 0;
    for (int i = 0; i < pl; i++) {
        s += A[i];
    }
    bool rev = 0;
    if (s * 2 >= S) {
        rev = 1;
        s = 0;
        reverse(A.begin(), A.end());
        for (int i = 0; i < pl; i++) {
            s += A[i];
        }
    }

    if (s * 2 >= S) {
        // 
    } else if ((s + A[pl]) * 2 >= S && (n % 2) == 1) {
        pl++;
    } else {
        for (int i = n / 2; i < n; i++) {
            pl--;
            s -= A[pl];
            sl++;
            s += A[n - sl];
            if (s * 2 >= S) {
                break;
            }
        }
    }

    //cout << rev << " " << sl << " " << pl << "\n";
    
    vector<signed> ans;
    ans.reserve(n);
    for (int i = 0; i < pl; i++) {
        ans.push_back(i);
    }
    for (int i = sl - 1; i >= 0; i--) {
        ans.push_back(n - 1 - i);
    }
    for (int i = pl; i < n - sl; i++) {
        ans.push_back(i);
    }
    if (rev) {
        for (int i = 0; i < n; i++) {
            ans[i] = n - 1 - ans[i];
        }
    }
    return ans;
}
