#include <bits/stdc++.h>

namespace operators
{
    template <typename T1, typename T2>
    std::istream &operator>>(std::istream &in, std::pair<T1, T2> &x)
    {
        in >> x.first >> x.second;
        return in;
    }

    template <typename T1, typename T2>
    std::ostream &operator<<(std::ostream &out, std::pair<T1, T2> &x)
    {
        out << x.first << " " << x.second;
        return out;
    }

    template <typename T1>
    std::istream &operator>>(std::istream &in, std::vector<T1> &x)
    {
        for (auto &i : x)
            in >> i;
        return in;
    }

    template <typename T1>
    std::ostream &operator<<(std::ostream &out, std::vector<T1> &x)
    {
        for (auto &i : x)
            out << i << " ";
        return out;
    }

    template <typename T1>
    std::ostream &operator<<(std::ostream &out, std::set<T1> &x)
    {
        for (auto &i : x)
            out << i << " ";
        return out;
    }
}
using namespace std;
using namespace operators;

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define uint unsigned int
#define all(vc) vc.begin(), vc.end()

// #define int ll

main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    if (n == 1)
    {
        cout << a << "\n";
        return 0;
    }

    int k = __lg(n + 1);
    map<int, int> cnt;

    for (int i = 0; i < n; ++i)
        cnt[a[i]]++;

    vector<vector<int>> cur(k + 1);

    for (auto [x, c] : cnt)
    {
        if (c > k)
        {
            cout << "-1\n";
            return 0;
        }
        cur[c].pb(x);
    }

    vector<int> lowest;
    for (int c = k; c > 0; --c)
    {
        if (c == k)
        {
            if (cur[c].size() != 1)
            {
                cout << "-1\n";
                return 0;
            }
            lowest.pb(cur[c][0]);
        }
        else
        {
            vector<pii> bf;
            for (int i = 0; i < lowest.size(); ++i)
                bf.pb({lowest[i], i});
            sort(all(bf));
            sort(all(cur[c]));
            if (cur[c].size() != lowest.size())
            {
                cout << "-1\n";
                return 0;
            }
            lowest.assign(2 * lowest.size(), 0);
            for (int i = 0; i < cur[c].size(); ++i)
            {
                if (lowest[i] >= cur[c][i])
                {
                    cout << "-1\n";
                    return 0;
                }
                int pos = bf[i].s;
                lowest[pos * 2] = bf[i].f;
                lowest[pos * 2 + 1] = cur[c][i];
            }
        }
    }
    cout << lowest << "\n";
}