#include <bits/stdc++.h>
using namespace std;
long long n, i, f[100009], dem, d[50], sum, a[50];
vector<long long> t;
stack<long long> ans;
long long mu(int u, int v) {
  if (v == 0) return 1;
  return u * mu(u, v - 1);
}
long long kt(long long u) {
  long long tong = 0;
  while (u > 1) {
    if (u % 2 == 1) return 0;
    tong++;
    u /= 2;
  }
  return tong;
}
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> f[i];
  for (i = 0; i < n; i++) {
    if (f[i] == 1)
      d[0]++, a[0] = d[0];
    else {
      dem = kt(f[i]);
      if (dem == (long long)0)
        t.push_back(f[i]), sum++;
      else {
        if (d[dem] < d[dem - 1])
          d[dem]++, a[dem] = d[dem];
        else
          t.push_back(f[i]), sum++;
      }
    }
  }
  n = t.size();
  while (a[0] > 0) {
    for (i = 0;; i++) {
      if (a[i] == 0) break;
      a[i]--;
    }
    if (n > 0)
      if (t[n - 1] >= mu(2, i)) {
        cout << -1;
        return 0;
      }
    n--;
  }
  if (sum > d[0]) {
    cout << -1;
    return 0;
  }
  i = 0;
  dem = d[0];
  n = d[0];
  while (d[i] >= sum) {
    while (d[i] == d[i + 1]) {
      i++;
    }
    sum += (i + 1);
    d[i]--;
    dem--;
  }
  for (i = dem + 1; i <= n; i++) cout << i << ' ';
}
