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

// maxsum

std::vector<int> solve(std::vector<int> A)
{
    const int maxN = 1e5 + 5;
    vector <int> ans;
    int n = A.size();
    int ind = 0, sum = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        mp[A[i]]++;
    }
    for (auto t : mp)
    {
        int num = t.second / 2;
        for (int j = 0; j < num; j++)
        {
            ans.push_back(t.first);
        }
    }
    for (int i = 0; i < n / 2; i++)
    {
        ans.push_back(ans[i]);
    }
    return ans;
}
