#include "partition.h"
//#include "grader.cpp"
using namespace std;
vector<int> solve(vector<int> A)
{
    int n = A.size(), i, j, l;
    long long z = 0, s = -1;
    for (auto& h : A)
        s += h;
    s >>= 1;
    vector<int> an(n);
    j = (n >> 1);
        for (i = 0; i < j; i++)
            z += A[i];
        if (z <= s)
        {
            for (i = 0; i < j; i++)
            {
                z += A[i + j] - A[i];
                if (z > s)
                {
                    l = i + 1;
                    for (auto& h : an)
                    {
                        h = l;
                        l++;
                        if (l == n)
                            l = 0;
                    }
                    return an;
                }
            }
            l = j;
            for (auto& h : an)
            {
                h = l;
                l++;
                if (l == n)
                    l = 0;
            }
            return an;
        }
        else
        {
            for (i = 0; i < j; i++)
            {
                z += A[i + j] - A[i];
                if (z <= s)
                {
                    l = i + j;
                    for (auto& h : an)
                    {
                        h = l;
                        l--;
                        if (l == -1)
                            l = n - 1;
                    }
                    return an;
                }
            }
            l = j;
            for (auto& h : an)
            {
                h = l;
                l++;
                if (l == n)
                    l = 0;
            }
        }
    return an;
}
