#include "partition.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fi first
#define sc second
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

const int MAXN = 2e5;
const ll inf = 1e18;
const int MAXV = (3e7) + 5;

std::vector<int> solve(std::vector<int> A) {
    ll sum = 0;
    int n = (int)A.size();
    deque<int> dq;
    unordered_map<int,int> cnt;
    for(int i=0; i<n; i++)sum+=A[i], cnt[A[i]]++;
    int goal = sum/2;

    /// check case
    bool case1 = true;
    bool case5 = (n<=7);
    bool case2 = true;
    for(int i=0; i<n; i++)if(cnt[A[i]]&1)case1 = 0;
    for(int i=0; i<n; i++)if(A[i]!=(1ll<<i))case2 = 0;
    vector<int> rez;
    if(case1)
    {
        for(int i=0; i<n; i++)
        {
            if(cnt[A[i]]&1)dq.push_back(i);
            else dq.push_front(i);
            cnt[A[i]] --;
        }
        while(!dq.empty())
        {
            rez.pb(dq.front());
            dq.pop_front();
        }
    }
    else if(case2)
    {
        rez.pb(n-1);
        for(int i=0; i<n-1; i++)rez.pb(i);
    }
    return rez;

}
