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 std::pair;
using std::vector;
vector<int64_t> ReadInput(std::istream& in_stream = std::cin);
void WriteAnswer(size_t min, size_t max, std::ostream& out_stream = std::cout);
pair<size_t, size_t> GetRange(const vector<int64_t>& input);
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  auto input = ReadInput();
  auto result = GetRange(input);
  WriteAnswer(result.first, result.second);
  return 0;
}
vector<int64_t> Power2();
pair<vector<size_t>, vector<size_t>> ChainsExtra(const vector<int64_t>& input);
template <class Integral, class Functional, class Check>
Integral BinSearch(Integral left, Integral right, Functional func, Check check);
pair<size_t, size_t> GetRange(const vector<int64_t>& input) {
  auto chains_extra = ChainsExtra(input);
  vector<size_t> chains = std::move(chains_extra.first);
  vector<size_t> extra = std::move(chains_extra.second);
  size_t sum_chains = 0, sum_extra = 0;
  for (size_t i = chains.size(); i > 0;
       --i, sum_chains += chains[i], sum_extra += extra[i]) {
    if (sum_extra > sum_chains) {
      return {1, 0};
    }
  }
  if (sum_extra > sum_chains) {
    return {1, 0};
  }
  size_t min = sum_chains, max = sum_chains;
  for (size_t i = 0; i < chains.size(); ++i) {
    if (min - chains[i] >= sum_extra + chains[i] * i) {
      min -= chains[i];
      sum_extra += chains[i] * i;
    } else {
      auto enouht = [min, &chains, sum_extra, sum_chains, i](size_t remove) {
        return min - remove >= sum_extra + remove * i;
      };
      auto diff = [](size_t l, size_t r) { return r <= l + 1; };
      min -= BinSearch(size_t(0), chains[i], enouht, diff);
      break;
    }
  }
  return {min, max};
}
template <class Integral, class Functional, class Check>
Integral BinSearch(Integral left, Integral right, Functional func, Check check);
pair<vector<size_t>, vector<size_t>> ChainsExtra(const vector<int64_t>& input) {
  vector<int64_t> pow2 = Power2();
  vector<size_t> count_pow2(pow2.size(), 0);
  vector<size_t> extra(pow2.size(), 0);
  auto diff = [](size_t l, size_t r) { return r <= l + 1; };
  for (auto elem : input) {
    size_t pos = BinSearch(
        size_t(0), pow2.size(),
        [&pow2, elem](size_t pos) { return pow2[pos] <= elem; }, diff);
    if (elem == pow2[pos]) {
      ++count_pow2[pos];
    } else {
      ++extra[pos + 1];
    }
  }
  auto get_last = [&count_pow2]() {
    for (int i = 0; i < count_pow2.size(); ++i) {
      if (count_pow2[i] == 0) {
        return i;
      }
    }
    return static_cast<int>(count_pow2.size());
  };
  vector<size_t> chains(pow2.size(), 0);
  while (get_last() != 0) {
    auto pos = get_last();
    auto chains_count =
        *std::min_element(count_pow2.begin(), count_pow2.begin() + pos);
    chains[pos] = chains_count;
    std::for_each(count_pow2.begin(), count_pow2.begin() + pos,
                  [chains_count](size_t& count) { count -= chains_count; });
  }
  for (size_t i = 0; i < pow2.size(); ++i) {
    extra[i] += count_pow2[i];
  }
  return {chains, extra};
}
template <class Integral, class Functional, class Check>
Integral BinSearch(Integral left, Integral right, Functional func,
                   Check check) {
  auto dir = func(left);
  while (!check(left, right)) {
    Integral mid = (left + right) / 2;
    if (func(mid) == dir) {
      left = mid;
    } else {
      right = mid;
    }
  }
  return left;
}
vector<int64_t> Power2() {
  std::vector<int64_t> power2{1};
  while (power2.back() < 1ll * 2000 * 1000 * 1000 * 1000) {
    power2.push_back(power2.back() * 2);
  }
  return power2;
}
void WriteAnswer(size_t min, size_t max, std::ostream& out_stream) {
  if (min > max) {
    out_stream << -1;
    return;
  }
  for (size_t i = min; i <= max; ++i) {
    std::cout << i << ' ';
  }
}
vector<int64_t> ReadInput(std::istream& in_stream) {
  size_t input_size;
  in_stream >> input_size;
  vector<int64_t> input(input_size);
  for (auto& elem : input) {
    in_stream >> elem;
  }
  return input;
}
