#include<iostream>
#include<vector>
using namespace std;
vector<int> solve(vector<int> A){
    const int MAXN = 2*1e6;
    const int MAXA = 3*1e7;
    int N = A.size();
    int arr [MAXN];
    int index = 0;
    vector <int> ans;
    vector <int> indexi[MAXA];
    for(int i = 0; i < N; i ++){
        indexi[A[i]].push_back(i);
    }
    for(int i = 1; i <= MAXA; i ++){
        for(int j = 0; j < indexi[i].size(); j += 2){
            arr[index] = indexi[i][j];
            arr[N - 1 - index] = indexi[i][j + 1];
            index ++;
        }
    }
    for(int i = 0; i < N; i ++){
        ans.push_back(arr[i]);
    }
    return ans;
}