#include <bits/stdc++.h>

using namespace std;

const long long inf = 1e18;

vector<int> solve(vector<int> a) {
    int n = a.size();
    map<int, bool> was;
    vector<bool> used(n);
    vector<int> ans;

    for (int i = 0; i < n; i++) {
        if (!was[a[i]]) {
            was[a[i]] = true;
            ans.push_back(i);
            used[i] = true;
        }
    }

    for (int i = 0; i < n; i++) {
        if (!used[i])
            ans.push_back(i);
    }
    return ans;
}