#include<bits/stdc++.h>
using namespace std;
using ll = long long;

vector<int> solve(vector<int> a){
    int n = a.size();

    map<int,vector<int>> freq;
    for(int i = 0; i < n; ++i){
        freq[a[i]].emplace_back(i);
    }

    vector<int> b;

    for(auto &[u,v] : freq){
        for(int i = 0; i < v.size()/2; ++i){
            b.emplace_back(v[i]);
        }
    }
    for(auto &[u,v] : freq){
        for(int i = v.size()/2; i < v.size(); ++i){
            b.emplace_back(v[i]);
        }
    }
    return b;
}

signed main(void){
    int n;
    cin >> n;

    vector<int> a(n);
    for(auto &i : a) cin >> i;

    vector<int> b = solve(a);
    for(auto &i : b) cout << i << " ";
}
