#include "partition.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN=2000000, MAXA=1000000000;

vector<int> subtask2(vector<int> a)
{
    int n=a.size();
    vector<int> ans;
    vector<bool> used(n);
    for(int i=0; i<n/2; i++)
    {
        ans.push_back(i);
        used[i]=1;
    }
    ans.push_back(n-1);
    used[n-1]=1;
    for(int i=n/2; i<n; i++)
    {
        if(!used[i])
        {
            ans.push_back(i);
            used[i]=1;
        }
    }
    return ans;
}

vector<int> subtask1(vector<int> a)
{
    int n=a.size();
    map<int, vector<int>> m;
    for(int i=0; i<n; i++)
    {
        m[a[i]].push_back(i);
    }

    vector<int> ans;
    for(auto [val, v]: m)
    {
        for(int i=0; i<v.size(); i+=2)
        {
            ans.push_back(v[i]);
        }
    }
    for(auto [val, v]: m)
    {
        for(int i=1; i<v.size(); i+=2)
        {
            ans.push_back(v[i]);
        }
    }

    return ans;
}

vector<int> solve(vector<int> A)
{
    if(A.size()==1)
    {
        return {A[0]};
    }

    return subtask2(A);
}

