#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
long long n, a[5000005], pw[300], btw[300], pw2[300], btw2[300];
vector<long long> vv[5000005];
bool poss(long long val) {
  for (int i = 0; i < 50; i++) pw2[i] = pw[i], btw2[i] = btw[i];
  for (int i = 1; i <= val; i++) {
    vv[i].clear();
    for (int j = 0; j < 50; j++) {
      if (pw2[j] > 0)
        pw2[j]--, vv[i].push_back(j);
      else {
        break;
      }
    }
  }
  int lft[50];
  for (int i = 0; i < 50; i++) {
    lft[i] = pw2[i] + btw2[i];
  }
  for (int i = 1; i <= val; i++) {
    for (int j = 49; j >= 0; j--) {
      if (lft[j] > 0) {
        int last = vv[i][vv[i].size() - 1];
        if (last < j)
          return false;
        else {
          lft[j]--;
          break;
        }
      }
    }
  }
  for (int i = 0; i < 50; i++)
    if (lft[i] > 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 50; j++) {
      long long val = 1LL << j;
      if (a[i] < val) {
        btw[j - 1]++;
        break;
      } else if (a[i] == val) {
        pw[j]++;
        break;
      }
    }
  }
  long long st = 0, en = pw[0], ans = 1e15;
  while (st <= en) {
    long long mid = (st + en) / 2LL;
    if (poss(mid))
      en = mid - 1, ans = min(ans, mid);
    else
      st = mid + 1;
  }
  if (ans == 1e15)
    cout << -1 << endl;
  else {
    for (int i = ans; i <= pw[0]; i++) cout << i << " ";
    cout << endl;
  }
  return 0;
}
