It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2k. Let's call that representation prairie partition of x.

For example, the prairie partitions of 12, 17, 7 and 1 are: 

12 = 1 + 2 + 4 + 5,

17 = 1 + 2 + 4 + 8 + 2,

7 = 1 + 2 + 4,

1 = 1. 

Alice took a sequence of positive integers (possibly with repeating elements), replaced every element with the sequence of summands in its prairie partition, arranged the resulting numbers in non-decreasing order and gave them to Borys. Now Borys wonders how many elements Alice's original sequence could contain. Find all possible options!

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of numbers given from Alice to Borys.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1012; a1 ≤ a2 ≤ ... ≤ an) — the numbers given from Alice to Borys.

Output

Output, in increasing order, all possible values of m such that there exists a sequence of positive integers of length m such that if you replace every element with the summands in its prairie partition and arrange the resulting numbers in non-decreasing order, you will get the sequence given in the input.

If there are no such values of m, output a single integer -1.

Examples

Input

8
1 1 2 2 3 4 5 8


Output

2 


Input

6
1 1 1 2 2 2


Output

2 3 


Input

5
1 2 4 4 4


Output

-1

Note

In the first example, Alice could get the input sequence from [6, 20] as the original sequence.

In the second example, Alice's original sequence could be either [4, 5] or [3, 3, 3].
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
int64_t fx[4] = {0, 1, 0, -1};
int64_t fy[4] = {1, 0, -1, 0};
const long long M = 2e5 + 10, M2 = 1e6 + 200, oo = 1e16 + 7, mod = 998244353;
const long long MC = (1 << 20) + 5;
int64_t ara[M];
int64_t can(int64_t n) {
  multiset<int64_t> st;
  for (int64_t i = 0; i < M; i++) {
    if (ara[i])
      st.insert(ara[i]);
    else
      break;
  }
  vector<int64_t> mxhere(n + 2, 0);
  int64_t pre = n;
  for (int64_t lvl = 0; lvl <= 40; lvl++) {
    int64_t cur = (1LL << lvl);
    pre = min(pre, (int64_t)st.count(cur));
    for (int64_t i = 0; i < pre; i++) {
      mxhere[i] = cur;
      st.erase(st.find(cur));
    }
  }
  for (int64_t i = 0; i < n; i++)
    if (mxhere[i] == 0) return 2;
  for (int64_t i = n - 1; i >= 0; i--) {
    if (st.size() == 0) return 1;
    auto it = st.begin();
    int64_t cur = *it;
    if (cur < mxhere[i] * 2) st.erase(st.find(cur));
  }
  return (st.size() == 0);
}
void precomp() {}
void solve() {
  int64_t n;
  cin >> n;
  for (int64_t i = 0; i < n; i++) {
    cin >> ara[i];
  }
  int64_t lo = 1, hi = n + 1;
  while (lo < hi) {
    int64_t mid = (lo + hi) / 2;
    if (can(mid) == 0)
      lo = mid + 1;
    else
      hi = mid;
  }
  int64_t lb = lo;
  lo = 1, hi = n + 1;
  while (lo < hi) {
    int64_t mid = (lo + hi) / 2;
    if (can(mid) < 2)
      lo = mid + 1;
    else
      hi = mid;
  }
  int64_t ub = lo;
  if (ub <= lb) {
    cout << -1 << endl;
    return;
  }
  for (int64_t i = lb; i < ub; i++) {
    cout << i << " ";
  }
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  precomp();
  solve();
  return 0;
}
