#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <iomanip> 
#include <random> 
#include <fstream> 
#include <set> 

#define ll long long 
#define ld long double 
using namespace std;
int main()
{
    int n; cin >> n;
    int k = (n + 1) / 2;
    vector <int> a(n);
    vector <pair<int, int>> cnt(k);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 1 || a[i] > k) {
            cout << -1;
            return 0;
        }
        cnt[a[i] - 1].first++;
        cnt[a[i] - 1].second = a[i];
    }
    sort(cnt.begin(), cnt.end());
    int h = log2(k) + 1;
    int m = h;
    bool b = 1;
    vector <int> tmin(n + 1);
    int l = 1, r = 1;
    while (h) {
        int c = 0;
        set<int> s;
        for (int i = k - 1; i >= 0; i--) {
            if (cnt[i].first >= h) {
                c++;
                s.insert(cnt[i].second);
            }
        }
        if (c == pow(2, m - h)) {
            int j = l;
            for (auto now : s) {
                tmin[j] = now;
                j++;
            }
        }
        else b = 0;
        l *= 2;
        h--;
    }
    if (!b) cout << -1;
    else {
        for (int i = 0; i < k; i++) {
            cout << tmin[n / 2 + i + 1] << " ";
        }
    }
    return 0;
}