#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
bool MinPlace(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
bool check(vector<int> &inp, vector<int> &reqs) {
  for (int i = 39, sum = 0; i >= 0; i--) {
    sum += inp[i] - (i != 39 ? inp[i + 1] : 0) - reqs[i];
    if (sum < 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<long long int> a(n);
  vector<int> inp(40, 0), reqs(40, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (__builtin_popcountll(a[i]) > 1)
      reqs[63 - __builtin_clzll(a[i])]++;
    else
      inp[63 - __builtin_clzll(a[i])]++;
  }
  for (int i = 1; i < 40; i++)
    if (inp[i] > inp[i - 1]) {
      reqs[i - 1] += inp[i] - inp[i - 1];
      inp[i] = inp[i - 1];
    }
  int j = 0, ans = check(inp, reqs);
  stack<int> output;
  if (ans)
    output.push(inp[0]);
  else {
    cout << "-1";
    return 0;
  }
  while (ans and inp[0] > 1) {
    for (; j < 40; j++) {
      if ((j == 39 and inp[j]) || (inp[j] > inp[j + 1])) {
        for (int k = 0; k <= j; k++) {
          inp[k]--;
          reqs[k - 1 >= 0 ? k - 1 : 0]++;
        }
        break;
      }
    }
    if (!check(inp, reqs)) break;
    output.push(inp[0]);
  }
  while (output.size()) {
    cout << output.top() << " ";
    output.pop();
  }
};
