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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef long long ll;
typedef vector<pi> vpi;
#define x first
#define y second
#define fr(n) for(int i = 0; i<n; i++)

vi solve(vi a)
{
    int n = a.size();
    vpi v(n);
    ll s1 = 0, s2 = 0;
    fr(n){
        v[i] = {a[i],i};
        if(i<n/2)
            s1 += a[i];
        else
            s2 += a[i];
    }
    if(s1>s2){
        vi h(n);
        fr(n)
            h[i] = a[n-i-1];
        vi h1 = solve(h);
        fr(n)
            h1[i] = n-1-h1[i];
        return h1;
    }
    int i = 0;
    while(s1<s2 && i<n/2){
        s1 -= v[i].x;
        s2 += v[i].x;
        s1 += v[(n+1)/2+i].x;
        s2 -= v[(n+1)/2+i].x;
        swap(v[i], v[(n+1)/2+i]);
        i++;
    }
    vi an(n);
    fr(n)
        an[i] = v[i].y;
    return an;
}
/*
int main()
{
    int t;
    cin >> t;
    fr(t){
        int n;
        cin >> n;
        vi v(n);
        fr(n) cin >> v[i];
        vi a = solve(v);
        fr(n) cout << a[i] << ' ';
        cout << '\n';
    }
}
*/