#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<functional>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<bit>

using namespace std;
//#define int long long
#define pii pair<int, int>
#define ll long long
#define ull unsigned ll
#define pll pair<ll, ll>
#define ve vector
#define vi ve<int>
#define vvi ve<vi>
#define vll ve<ll>
#define tiii tuple<int, int, int>
#define tiiii tuple<int, int, int, int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a= max(a, b)
#define all(a) a.begin(), a.end()
#define for0(i, n) for(int i= 0; i < n; ++i)

extern vector<int> solve(vector<int> A) {
    int n = A.size();
    ve<pii> a(n);
    for0(i, n) {
        a[i] = { A[i], i };
    }
    sort(all(a));
    vi ans1, ans2; ans1.reserve(n); ans2.reserve(n / 2);
    ve<pii> b;
    for (int i = 0; i < n; ++i) {
        if (i + 1 < n && a[i].first == a[i + 1].first) {
            ans1.push_back(a[i].second); ans2.push_back(a[i + 1].second); ++i;
        }
        else b.push_back(a[i]);
    }
    for (int i = 0; i < b.size() - 1; ++i) {
        ans1.push_back(b[i].second);
        if (i == (b.size() - 1) / 2) ans1.push_back(b.back().second);
    }
    for (auto now : ans2) ans1.push_back(now);
    return ans1;
}