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 INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
long long int pot[60];
int n;
map<long long int, int> mapa;
long long int v[N];
vector<long long int> coco;
long long int pode[60];
long long int fixa[60];
int ondemax() {
  int i;
  for (i = 59; i >= 0; i--)
    if (pot[i] != 0) return i;
  return -1;
}
int getmin() {
  int ret;
  int i = ondemax();
  int mini = pot[i];
  for (; i >= 0; i--)
    if (mini > pot[i]) mini = pot[i];
  return mini;
}
int qnts_livres() {
  int x = 0;
  for (int i = 1; i < 60; i++) x += pode[i];
  return x;
}
void tira(int x) {
  for (int i = 59; i >= 1; i--)
    while (x > 0 and pode[i] > 0) pode[i]--, x--;
  assert(x == 0);
}
void resolve() {
  long long int r = 0;
  sort(coco.begin(), coco.end());
  int x = coco.size() - 1;
  long long int livre = 0;
  for (long long int i = 59; i > 0; i--) {
    if (fixa[i] == 0) continue;
    long long int proxfixa = 1;
    for (proxfixa = i - 1; proxfixa >= 0; proxfixa--)
      if (fixa[proxfixa]) break;
    long long int cont = 0;
    r += fixa[i];
    livre += fixa[i];
    if (x >= 0 and coco[x] > (1ll << (i + 1))) {
      cout << -1 << endl;
      return;
    }
    while (x >= 0 and coco[x] >= (1ll << (proxfixa + 1))) {
      cont++;
      x--;
    }
    if (cont > livre) {
      cout << -1 << endl;
      return;
    }
    livre -= cont;
  }
  if (x + 1 > livre) {
    cout << -1 << endl;
    return;
  }
  livre -= x + 1;
  int c = 0;
  while (livre > 0 and fixa[0] > 0) livre--, fixa[0]--, c++;
  while (fixa[0] > 1) fixa[0] -= 2, c++, r++;
  r += fixa[0];
  pode[0] = 0;
  for (long long int i = 1; i < 60; i++) {
    int x = min(livre, fixa[i]);
    pode[i] = x;
    livre -= x;
  }
  for (long long int i = 1; i < 60; i++) {
    while (qnts_livres() > i + 1 and pode[i] > 0) {
      pode[i]--;
      tira(i + 1);
      r--, c++;
    }
  }
  for (int i = 0; i <= c; i++) cout << r + i << " ";
  cout << endl;
}
int main() {
  for (long long int i = 0; i < 60; i++) mapa[1ll << i] = i + 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    int x = mapa[v[i]];
    if (x > 0) {
      pot[x - 1]++;
    } else
      coco.push_back(v[i]);
  }
  long long int r = 0;
  for (int i = 0; i < 60; i++) {
  }
  while (true) {
    int x = ondemax();
    if (x == -1) break;
    int val = getmin();
    fixa[x] = val;
    for (int i = 0; i <= x; i++) pot[i] -= val;
    while (pot[x] > 0) {
      coco.push_back(1ll << x);
      pot[x]--;
    }
  }
  resolve();
  return 0;
}
