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

// maxsum

std::vector<int> solve(std::vector<int> A)
{
    vector <int> ans;
    int n = A.size();
    if (n == 1)
    {
        return {A[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;
}
