#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include<deque>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int k = log2(n + 1);
    vector<int> d(n);
    set<int> s;
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        s.insert(d[i]);
        m[d[i]] += 1;
    }
    vector<deque<int>> p(k - 1);
    vector<int> ans((n - 1) / 2 + 1);
    if (m[*s.begin()] != k) {
        cout << "-1";
        exit(0);
    }
    ans[0] = *s.begin();
    for (int i = 0; i < k - 1; i++) {
        p[i].push_back(i + 1);
    }
    s.erase(s.begin());
    for (auto i : s) {
        m[i]--;
        if (p[m[i]].size() == 0) {
            cout << "-1";
            exit(0);
        }
        ans[p[m[i]].front()] = i;
        int id = p[m[i]].front();
        for (int j = 0; j < m[i]; j++) {
            p[j].push_back(id + j + 1);
        }
        p[m[i]].pop_front();
    }
    for (auto i : ans) {
        cout<<i<<' ';
    }
}