# include <iostream>
# include <map>
# include <vector>
using namespace std;
# include "partition.h"
//# include "grader.cpp"

const int MAX=(1<<22);

int n;
long long a[MAX];

std::vector<int> solve(std::vector<int> A)
{
    n=A.size();
    for(int i=0;i<n;i++) a[i]=A[i];

    map<int,int> mp;
    vector<int> L,R;
    for(int i=0;i<n;i++)
    {
        if(mp.find(a[i])==mp.end()) mp[a[i]]=i;
        else
        {
            L.push_back(mp[a[i]]);
            R.push_back(i);
            mp.erase(a[i]);
        }
    }

    vector<int> ans;
    for(int x: L) ans.push_back(x);
    for(int x: R) ans.push_back(x);
    return ans;
}

