#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, cnt;
long long a[N], val[N];
bool check(long long x, long long y) {
  if (x == 1 && y == 0) return 1;
  return x == y * 2;
}
bool check(int m) {
  fill_n(val + 1, m, 0);
  vector<long long> v;
  int p = 1;
  for (int i = (1); i < (n + 1); ++i) {
    if (i == 1 || a[i] != a[i - 1]) p = 1;
    if (check(a[i], val[p])) {
      val[p] = a[i];
      p++;
      if (p > m) p = 1;
    } else {
      v.push_back(a[i]);
    }
  }
  if ((int)v.size() > m) return 0;
  for (int i = (1); i < (m + 1); ++i) val[i] = val[i] * 2 - 1;
  reverse(v.begin(), v.end());
  for (int i = (0); i < ((int)v.size()); ++i)
    if (v[i] > val[i + 1]) return 0;
  return 1;
}
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  cin >> n;
  for (int i = (1); i < (n + 1); ++i) cin >> a[i], cnt += (a[i] == 1);
  if (check(cnt)) {
    int l = 1, r = cnt, ans = -1;
    while (l <= r) {
      int mid = l + r >> 1;
      if (check(mid)) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    assert(ans != -1);
    for (int i = (ans); i < (cnt + 1); ++i) cout << i << " \n"[i == cnt];
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
