#include <bits/stdc++.h>
using namespace std;
const int MP = 60;
map<long long, int> pw;
long long inpw[MP];
map<int, int> seq;
void pre_calc() {
  inpw[0] = 1;
  pw[1] = 0;
  for (int i = 1; i < MP; i++) {
    inpw[i] = inpw[i - 1] * 2LL;
    pw[inpw[i]] = i;
  }
}
int main() {
  ios::sync_with_stdio(0);
  pre_calc();
  int n;
  cin >> n;
  vector<long long> bad;
  for (int i = 0; i < n; i++) {
    long long v;
    cin >> v;
    if (!pw.count(v)) {
      bad.push_back(v);
      continue;
    }
    if (v == 1) {
      seq[0]++;
    } else {
      int lw = pw[v] - 1;
      if (seq.count(lw)) {
        seq[lw]--;
        seq[lw + 1]++;
        if (!seq[lw]) {
          seq.erase(lw);
        }
      } else {
        bad.push_back(v);
      }
    }
  }
  int ans = 0;
  int cnt = 1;
  for (auto sq : seq) {
    ans += sq.second;
  }
  for (int i = bad.size() - 1; i >= 0; i--) {
    map<int, int>::reverse_iterator it = seq.rbegin();
    if (seq.empty()) {
      cout << "-1";
      return 0;
    }
    int p = it->first;
    if (bad[i] >= inpw[p + 1]) {
      cout << "-1";
      return 0;
    }
    seq[p]--;
    if (!seq[p]) seq.erase(p);
  }
  bool ok = 1;
  for (int powr = 0; powr < 60; powr++) {
    if (seq.empty()) break;
    if (!seq.count(powr)) continue;
    int p = powr;
    while (seq.count(p) && ok) {
      seq[p]--;
      if (!seq[p]) seq.erase(p);
      if (seq.empty()) {
        ok = 0;
        break;
      }
      for (int i = 0; i < p + 1; i++) {
        if (seq.empty()) {
          ok = false;
          break;
        }
        int lastP = (*seq.rbegin()).first;
        seq[lastP]--;
        if (!seq[lastP]) {
          seq.erase(lastP);
        }
      }
      if (!ok) break;
      cnt++;
      if (seq.empty()) break;
    }
    if (!ok) break;
    if (seq.empty()) break;
  }
  vector<int> farray;
  while (cnt--) farray.push_back(ans--);
  for (int i = farray.size() - 1; i >= 0; i--) {
    cout << farray[i] << " ";
  }
}
