#include "partition.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

using ll = long long;
vector<int> solve(vector<int>v) {
    int n = v.size();
    for(int k = n/2-1; k <= (n+1)/2-1; k++)
    {
        ll sum = 0;
        int idm = 0;
        vector<int> res(n);
        int sz = 0;
        for(int i = 0; i < n ;i++)
        {
            if(v[i]>v[idm])idm = i;
            sum+=v[i];
        }
        int mx = v[idm];
        v.erase(v.begin()+idm);
    
        if(n==1)
        {
            return {0};
        }
        n--;
        ll st = (sum+1)/2;
        ll ini = 0;
        for(int i = 0; i < k; i++)
            ini+=v[i];
        int i = 0;
        for(;i < n && (ini>=st||ini<st-mx); i++)
            ini-=v[i]-v[(i+k)%n];
        
        for(int j = i;j != (i+k)%n;j=(j+1)%n)
            res[sz++]=j+(j>=idm);
        res[sz++]=idm;
        for(int j = (i+k)%n;j!=i;j=(j+1)%n)
            res[sz++]=j+(j>=idm);
        n++;
        if(ini<st&&ini+mx>=st)
        return res;
        v.insert(v.begin()+idm,mx);
    }
    assert(0);
    return {0};
}
