#include <array>
#include <functional>
#include <iostream>
#include <cstdint>
#include <vector>
#include <cmath>
#include <unordered_set>


bool build(int v, int &ind, const std::vector<int> &values, std::vector<int> &tree) {
    tree[v] = values[ind];
    ind += 1;
    if (2 * v + 1 >= values.size()) {
        return true;
    }

    if (!build(2 * v + 1, ind, values, tree)) {
        return false;
    }

    if (!build(2 * v + 2, ind, values, tree)) {
        return false;
    }

    if (std::min(tree[2 * v + 1], tree[2 * v + 2]) != tree[v]) {
        return false;
    }

    return true;
}


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    uint64_t n;
    std::cin >> n;
    std::vector<int> values(n);

    for (auto &el: values) {
        std::cin >> el;
    }

    std::sort(values.begin(), values.end());

    std::vector<int> tree(n);
    int idx = 0;
    if (!build(0, idx, values, tree)) {
        std::cout << -1;
        return 0;
    }

    int first_idx = (n + 1) / 2 - 1;
    std::unordered_set<int> equals;

    for (int i = first_idx; i < tree.size(); ++i) {
        if (equals.find(tree[i]) != equals.end()) {
            std::cout << -1;
            return 0;
        }

        equals.insert(tree[i]);
    }

    for (int i = first_idx; i < tree.size(); ++i) {
        std::cout << tree[i] << ' ';
    }

    return 0;
}