#include <bits/stdc++.h>
using namespace std;
long long n;
map<long long, long long> cnt;
bool ok(long long x) {
  long long towers = x;
  vector<long long> t;
  map<long long, long long> curM(cnt.begin(), cnt.end());
  for (long long i = 1; true; i *= 2) {
    if (towers > cnt[i]) {
      long long rem = towers - cnt[i];
      for (long long j = 0; j < rem; j++) t.push_back(i);
    }
    towers = min(towers, cnt[i]);
    curM[i] -= towers;
    if (towers == 0) break;
  }
  vector<long long> v;
  for (pair<long long, long long> p : curM) {
    for (long long i = 0; i < p.second; i++) v.push_back(p.first);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  reverse(t.begin(), t.end());
  if (v.empty()) return true;
  if (v.size() > t.size()) return false;
  bool flag = true;
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] > t[i]) flag = false;
  }
  return flag;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    cnt[x]++;
  }
  long long l = 1;
  long long r = n;
  while (r - l > 3) {
    long long mid = (r - l) / 2 + l;
    if (ok(mid))
      r = mid;
    else
      l = mid;
  }
  long long s = -1;
  for (long long i = l; i <= r; i++)
    if (ok(i)) {
      s = i;
      break;
    }
  if (s == -1) {
    cout << "-1\n";
    exit(0);
  }
  for (long long i = s; i <= cnt[1]; i++) cout << i << ' ';
  cout << '\n';
}
