#include <bits/stdc++.h>

using namespace std;

const long long inf = 1e18;

vector<int> solve(vector<int> a) {
    int n = a.size();
    map<int, vector<int>> pos;
    vector<int> ans;

    for (int i = 0; i < n; i++)
        pos[a[i]].push_back(i);

    for (auto &[x, y] : pos) {
        for (int i = 0; i < y.size() / 2; i++)
            ans.push_back(y[i]);
    }

    for (auto &[x, y] : pos) {
        for (int i = y.size() / 2; i < y.size(); i++)
            ans.push_back(y[i]);
    }

    return ans;
}
