#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k, i, x;
set<int> st;

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	k = __lg(n + 1);
	for (i = 1; i <= n; i++) {
		cin >> x;
		st.insert(x);
	}
	k = (1ll << (k - 1));
	//cout << k << "\n";
	if (st.size() > k) {
		cout << "-1\n";
	}
	else if (st.size() == k) {
		for (int i : st) cout << i << " ";
		cout << "\n";
	}
	else cout << "-1\n";
}