#include <bits/stdc++.h>

using namespace std;

map <int, int> mp;

vector <int> solve ( vector <int> A ) {
    vector <int> ans = {};
    mp.clear();
    for ( auto it: A ) {
        mp[it]++;
    }
    for ( auto it: mp ) {
        for ( int i = 1; i <= it.second/2; i++ ) {
            ans.push_back (it.first);
        }
    }
    for ( auto it: mp ) {
        for ( int i = 1; i <= it.second/2; i++ ) {
            ans.push_back (it.first);
        }
    }

    return ans;
}