#include <bits/stdc++.h>
using namespace std;
using ll = long long;



void gg(vector<pair<int,int>> &A){
    int N = A.size();
    vector<queue<pair<int,int>>> vec(1000);
    for(int i = 0; i < N; ++i){
        vec[(A[i].first - 1) % 1000].push(A[i]);
    }
    int t = 0;
    for(int i = 0; i < 1000; ++i){
        while(vec[i].size() > 0){
            A[t] = vec[i].front();
            t++;
            vec[i].pop();
        }
    }
    for(int i = 0; i < N; ++i){
        vec[((A[i].first - 1) / 1000) % 1000].push(A[i]);
    }
    t = 0;
    for(int i = 0; i < 1000; ++i){
        while(vec[i].size() > 0){
            A[t] = vec[i].front();
            t++;
            vec[i].pop();
        }
    }
    for(int i = 0; i < N; ++i){
        vec[((A[i].first - 1) / 1000000)].push(A[i]);
    }
    t = 0;
    for(int i = 0; i < 1000; ++i){
        while(vec[i].size() > 0){
            A[t] = vec[i].front();
            t++;
            vec[i].pop();
        }
    }
}

void ff(vector<pair<int,int>> &A){
    int N = A.size();
    vector<queue<pair<int,int>>> vec(100000);
    for(int i = 0; i < N; ++i){
        vec[A[i].first % 100000].push(A[i]);
    }
    int t = 0;
    for(int i = 0; i < 100000; ++i){
        while(vec[i].size() > 0){
            A[t] = vec[i].front();
            t++;
            vec[i].pop();
        }
    }
    for(int i = 0; i < N; ++i){
        vec[A[i].first / 100000].push(A[i]);
    }
    t = 0;
    for(int i = 0; i < 100000; ++i){
        while(vec[i].size() > 0){
            A[t] = vec[i].front();
            t++;
            vec[i].pop();
        }
    }
}


vector<int> solve(vector<int> A) {
    int N = B.size();
    int n = (N + 1) / 2;
    if(N == 1){
        return{0};
    }
    
    
    
    
    
    
    ll num = 0;
    ll sum = 1;
    for(int i = 0; i < n; ++i){
        num += A[i];
        sum += A[i];
    }
    for(int i = n; i < N; ++i){
        sum += A[i];
    }
    bool k = 1;
    if(num > (sum / 2)){
        k = -1;
    }
    sum /= 2;
    sum -= num;
    int t = 0;
    while(((sum * k) > 0)){
        sum += A[t];
        sum -= A[(N - 1) - t];
        t++;
    }
    vector<int> vec;
    for(int i = t; i < n; ++i){
        vec.push_back(i);
    }
    for(int i = N - t; i < N; ++i){
        vec.push_back(i);
    }
    for(int i = n; i < N - t; ++i){
        vec.push_back(i);
    }
    for(int i = 0; i < t; ++i){
        vec.push_back(i);
    }
    return vec;

}

/*
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t ;
    for (int test=1; test<=t; test++) {
        int n;
        cin >> n ;
        vector <int> a(n);
        for (int i=0; i<n; i++) {
            cin >> a[i] ;
        }

        for (auto ind : solve(a)) {
            cout << ind << " ";
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}
//*/











