#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define kchau ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

const ll INF = 1e18 + 7;
const ll MOD = 1e9 + 7;
const ll SP = 2e5 + 7;
const ll N = 1e6 + 7;

using namespace std;

ll a[SP];

int main(){
  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  kchau
  ll n; cin >> n;
  map<ll, ll> mp;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  ll m = mp.size();
  ll k = 1;
  while(m / 2 != 1 && m != 1){
    m /= 2;
    k++;
  }
  vector<ll> x, y;
  for(auto it : mp){
    x.pb(it.S);
  }
  sort(rall(x));
  ll cnt = k + 1, ct = 1;
  y.pb(cnt);
  for(int i = 1; i <= k; i++){
    cnt--;
    for(int j = 1; j <= ct; j++){
      y.pb(cnt);
    }
    ct *= 2;
  }
  if(x.size() != y.size()) return cout << -1, 0;
  for(int i = 0; i < x.size(); i++){
    if(x[i] != y[i]) return cout << -1, 0;
    // cout << x[i] << " " << y[i] << '\n';
  }
  for(auto it : mp){
    cout << it.F << " ";
  }
  return 0;
}