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>
using namespace std;
const int N = 1e5 + 5;
long long int n, cnt1;
vector<long long int> v(N);
map<long long int, long long int> m;
bool check() {
  multiset<long long int> s;
  for (long long int i = (long long int)0; i <= (long long int)n - 1; i++)
    s.insert(v[i]);
  bool poss = true;
  multiset<long long int> la;
  while (!s.empty()) {
    long long int in = 1, last = 0;
    if (s.find(in) == s.end()) break;
    while (s.find(in) != s.end()) {
      auto it = s.find(in);
      s.erase(it);
      last = in;
      in *= 2;
    }
    la.insert(last);
  }
  for (auto x : s) {
    auto it = la.lower_bound((x + 1) / 2);
    if (it == la.end()) {
      poss = false;
      break;
    }
    la.erase(it);
  }
  if (!poss) return false;
  return true;
}
bool f(long long int x) {
  m.clear();
  for (long long int i = (long long int)0; i <= (long long int)n - 1; i++)
    m[v[i]]++;
  vector<long long int> last(x, 1);
  long long int in = 2, cnt = x;
  m[1] -= x;
  while (m[in] > 0 && cnt > 0) {
    long long int inc = m[in];
    long long int cc = min(cnt, inc);
    m[in] -= cc;
    cnt = cc;
    for (long long int i = (long long int)0; i <= (long long int)cc - 1; i++)
      last[i] = in;
    in *= 2;
  }
  multiset<long long int> la;
  for (long long int i = (long long int)0; i <= (long long int)x - 1; i++)
    la.insert(last[i]);
  for (auto x : m) {
    long long int in = x.first, cnt = x.second;
    for (long long int i = (long long int)1; i <= (long long int)cnt; i++) {
      auto it = la.lower_bound((in + 1) / 2);
      if (it == la.end()) return false;
      la.erase(it);
    }
  }
  return true;
}
int main() {
  cin >> n;
  for (long long int i = (long long int)0; i <= (long long int)n - 1; i++)
    cin >> v[i], cnt1 += (v[i] == 1);
  if (!check()) {
    cout << -1 << "\n";
    return 0;
  }
  long long int l = 0, r = cnt1 + 1;
  while (l < r - 1) {
    long long int m = l + (r - l) / 2;
    if (f(m))
      r = m;
    else
      l = m;
  }
  long long int mi = r;
  for (long long int i = (long long int)mi; i <= (long long int)cnt1; i++)
    cout << i << " ";
}
