#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	int col = 0;
	for(int i = 1; i <= 17; i ++){
		if((1 << i) - 1 == n){
			col = i - 1;
			break;
		}
	}
	map<int,int> cnt;
	for(int i = 1; i <= n; i ++){
		cnt[a[i]] ++;
	}
	if(cnt.size() != (1 << col)){
		cout << -1;
		return 0;
	}
	if(n == 1){
		cout << a[1];
		return 0;
	}
	if(cnt[a[1]] != col + 1){
		cout << -1;
		return 0;
	}
	int cur = col + 1;
	for(auto i : cnt){
		if(i.first == a[1]) continue;
		i.second --;
//		cout << i.first << " " << i.second << " " << col << "\n";
		if(i.second > col){
//			cout << i.first << " " << i.second << "\n";
			cout << -1;
			return 0;
		}
		col --;
	}
	for(auto i : cnt){
		cout << i.first << " ";
	}
}
