#include <bits/stdc++.h>
void read(long long &t) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  t = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') (t *= 10) += c - '0';
}
static const long long N = 100010;
long long a[N], cnt[45];
bool is_power(long long t) { return !(t - (t & -t)); }
long long get_cnt(long long t) {
  long long ret = -1;
  while (t) t >>= 1, ++ret;
  return ret;
}
signed main() {
  long long n;
  read(n);
  for (long long i = 0; i < n; ++i) read(a[i]);
  for (long long i = 0; i < n; ++i)
    if (is_power(a[i])) ++cnt[get_cnt(a[i])];
  long long mx = cnt[0], mn = 0;
  for (long long i = n - 1; i >= 0; --i)
    if (!is_power(a[i])) {
      long long c = get_cnt(a[i]);
      for (long long j = 44; j >= c; --j)
        if (cnt[j] > 0) {
          for (long long k = j; ~k; --k) --cnt[k];
          goto find;
        }
      printf("-1\n");
      return 0;
    find:
      ++mn;
    }
  while (cnt[0] > 0)
    for (long long i = 1; i < 45; ++i)
      if (cnt[i] <= 0) {
        for (long long j = 0; j < i; ++j) --cnt[j];
        long long mx = 0, p = -1;
        for (long long j = i - 1; j >= 0; --j)
          if (cnt[j] > mx) mx = cnt[p = j];
        if (mx) --cnt[p];
        ++mn;
        break;
      }
  for (long long i = 0; i < 45; ++i)
    if (cnt[i]) {
      printf("-1\n");
      return 0;
    }
  for (long long i = mn; i <= mx; ++i) printf("%lld ", i);
  printf("\n");
  return 0;
}
