// библитеки
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <cmath>
#include <random>
#include <bitset>

// сокращения типов
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

// константы
const ll M = 1e9 + 7;
const ll M1 = 1e9 + 9;
const ll P = 239;
const ll P1 = 137;
const ll INF = 1e9 + 7;
const ll INFll = 2e18;
const ld EPS = 1e-10;
const ld PI = atan2(0, -1);

// геометрия
struct Point {
	ld x, y;
	Point(ld xx = 0, ld yy = 0) {
		x = xx;
		y = yy;
	}
};

struct Vector {
	ld x, y, len, len_2;
	Vector(ld xx = 0, ld yy = 0) {
		x = xx;
		y = yy;
		len_2 = xx * xx + yy * yy;
		len = sqrtl(xx * xx + yy * yy);
	}
};

istream& operator >>(istream& in, Point& A) {
	in >> A.x >> A.y;
	return in;
}

ostream& operator <<(ostream& out, Point& A) {
	out << A.x << " " << A.y;
	return out;
}

Vector operator -(Point B, Point A) {
	return Vector(B.x - A.x, B.y - A.y);
}

Vector operator +(Vector a, Vector b) {
	return Vector(a.x + b.x, a.y + b.y);
}

Vector operator -(Vector a, Vector b) {
	return Vector(a.x - b.x, a.y - b.y);
}

Point operator +(Point A, Vector a) {
	return Point(A.x + a.x, A.y + a.y);
}

Point operator -(Point A, Vector a) {
	return Point(A.x - a.x, A.y - a.y);
}

ld operator *(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

ld operator ^(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

Vector operator *(Vector a, ld k) {
	return Vector(a.x * k, a.y * k);
}

struct Line {
	ld a, b, c;
	Point A, B;
	Vector ab;
	Line(Point C = { 0, 0 }, Point D = { 0, 1 }, ld aa = 0, ld bb = 1, ld cc = 0) {
		a = aa;
		b = bb;
		c = cc;
		if (a == 0) {
			A = { 0, -cc / bb };
			B = { 1, -(cc + aa) / bb };
		}
		else {
			A = { -cc / aa, 0 };
			B = { -(cc + bb) / aa, 1 };
		}
		ab = B - A;
		Vector cd = D - C;
		if (fabs(c) < EPS && fabs(a) < EPS && fabs(b - 1) < EPS) {
			ab = cd;
			A = C;
			B = D;
			a = C.y - D.y;
			b = D.x - C.x;
			c = -a * C.x - b * C.y;
		}
	}
};

Point cross_line(Line l1, Line l2) {
	if (fabs(l1.ab ^ l2.ab) < EPS && fabs(l1.a * l2.c - l1.c * l2.a) < EPS) {
		return l1.A;
	}
	if (fabs(l1.ab ^ l2.ab) < EPS && fabs(l1.a * l2.c - l1.c * l2.a) > EPS) {
		return 0;
	}
	ld d = l1.a * l2.b - l2.a * l1.b;
	return { (l2.c * l1.b - l2.b * l1.c) / d, -(l1.a * l2.c - l2.a * l1.c) / d };
}

ld angle_0_2p(Vector a, Vector b) {
	ld res = atan2(a ^ b, a * b);
	if (res < 0) {
		res += PI + PI;
	}
	return res;
}

ld angle_abs_p(Vector a, Vector b) {
	return atan2(a ^ b, a * b);
}

bool bel_p_line(Point A, Point B, Point C) {
	Vector ab = B - A, ac = C - A;
	if ((ab ^ ac) == 0) {
		return true;
	}
	return false;
}

bool bel_p_ray(Point A, Point B, Point C) {
	Vector ab = B - A, ac = C - A;
	if ((ab ^ ac) == 0 && (ab * ac) >= 0) {
		return true;
	}
	return false;
}

bool bel_p_segment(Point A, Point B, Point C) {
	Vector ab = B - A, ac = C - A;
	Vector ba = A - B, bc = C - B;
	if ((ab ^ ac) == 0 && (ab * ac) >= 0 && (ba * bc) >= 0) {
		return true;
	}
	return false;
}

bool bel_p_angle(Point A, Point O, Point B, Point C) {
	Vector oa = A - O, ob = B - O, op = P - O;
	if ((ob ^ oa) * (ob ^ op) > -EPS && (oa ^ op) * (oa ^ ob) > -EPS) {
		return true;
	}
	return false;
}

ld dist_p_line(Point A, Point B, Point C) {
	Line l(A, B);
	return fabs(l.a * C.x + l.b * C.y + l.c) / sqrtl(l.a * l.a + l.b * l.b);
}

ld dist_p_ray(Point A, Point B, Point C) {
	Vector ab = B - A, ac = C - A;
	if ((ab * ac) >= 0) {
		Line l(A, B);
		return fabs(l.a * C.x + l.b * C.y + l.c) / sqrtl(l.a * l.a + l.b * l.b);
	}
	else {
		return ac.len;
	}
}

ld dist_p_segment(Point A, Point B, Point C) {
	Vector ab = B - A, ac = C - A, ba = A - B, bc = C - B;
	if ((ab * ac) < 0) {
		return ac.len;
	}
	if ((ba * bc) < 0) {
		return bc.len;
	}
	Line l(A, B);
	return fabs(l.a * C.x + l.b * C.y + l.c) / sqrtl(l.a * l.a + l.b * l.b);
}

// не трогать, пока не требуется!
mt19937 rnd(time(0));

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	//freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);

	//cout << fixed << setprecision(20);

	int n;
	cin >> n;
	map<int, int> a;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a[x]++;
	}
	vector<int> b;
	for (auto x : a) {
		b.push_back(x.second);
	}
	bool f = true;
	for (int i = b.size() - 1; i >= 0; --i) {
		int y = b.size() - i;
		int z = 0;
		while (y != 0) {
			z++;
			y >>= 1;
		}
		if (b[i] > z) {
			f = false;
		}
	}
	int k = 0;
	int n1 = n + 1;
	while (n1 != 0) {
		k++;
		n1 >>= 1;
	}
	k -= 2;
	n1 = (1 << k);
	if (b.size() != n1) {
		f = false;
	}
	map<int, int> c;
	for (auto x : a) {
		c[x.second]++;
	}
	vector<int> c1;
	int max_x = 0, max_y = 0;
	for (auto x : c) {
		if (x.first > max_x) {
			max_x = x.first;
			max_y = x.second;
		}
		c1.push_back(x.second);
	}
	if (max_x > k + 1) {
		f = false;
	}
	reverse(c1.begin(), c1.end());
	int cnt = 0;
	int i = 1;
	for (auto x : c1) {
		if (x != (i - cnt)) {
			f = false;
		}
		if (cnt == 0) {
			cnt++;
			i *= 2;
		}
		else {
			cnt *= 2;
			i *= 2;
		}
	}
	if (f) {
		for (auto x : a) {
			cout << x.first << " ";
		}
	}
	else {
		cout << -1;
	}


	/*int n, q, k;
	cin >> n >> q >> k;
	vector<vector<int>> p(n);
	p[0].resize(n);
	for (int i = 0; i < n; ++i) cin >> p[i];*/
}