#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();
    map<int, int> mp;
    vector <bool> used(n);
    for (int i = 0; i < n; i++)
    {
        mp[A[i]]++;
    }
    for (auto& t : mp)
    {
        t.second = t.second / 2;
    }
    for (int i = 0; i < n; i++)
    {
        if (mp[A[i]] != 0)
        {
            ans.push_back(i);
            used[i] = true;
            mp[A[i]]--;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (!used[i])
        {
            ans.push_back(i);
        }
    }
    return ans;
}
