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].
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Div2_412E {

	static int[] pOf2Cnt;
	static int[] lessCnt;
	static int[] pOf2CntM;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int numE = Integer.parseInt(reader.readLine());

		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		reader.close();

		long[] pOf2 = new long[41];
		pOf2[0] = 1;
		for (int i = 1; i <= 40; i++) {
			pOf2[i] = pOf2[i - 1] << 1;
		}

		pOf2Cnt = new int[41];
		lessCnt = new int[41];
		pOf2CntM = new int[41];

		for (int i = 0; i < numE; i++) {
			long nLong = Long.parseLong(inputData.nextToken());
			for (int j = 0; j <= 40; j++) {
				if (nLong < pOf2[j]) {
					lessCnt[j]++;
					break;
				} else if (nLong == pOf2[j]) {
					pOf2Cnt[j]++;
					break;
				}
			}
		}

		pOf2CntM[0] = pOf2Cnt[0];
		for (int i = 1; i <= 40; i++) {
			pOf2CntM[i] = Math.min(pOf2CntM[i - 1], pOf2Cnt[i]);
		}

		if (!possible(pOf2Cnt[0])) {
			printer.println(-1);
			printer.close();
			return;
		}

		int low = 0;
		int high = pOf2Cnt[0];

		// finds the min value for which it is still possible
		while (low < high) {
			int mid = (low + high) >> 1;

			if (!possible(mid)) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}

		for (int i = low; i <= pOf2Cnt[0]; i++) {
			printer.print(i + " ");
		}
		printer.println();
		printer.close();
	}

	static boolean possible(int numCh) {
		int[] numEnd = new int[41];
		int[] numRem = Arrays.copyOf(lessCnt, 42);

		int numCmp = 0;
		for (int cPow = 40; cPow >= 0; cPow--) {
			int extra = Math.min(numCh - numCmp, pOf2CntM[cPow] - numCmp);
			numCmp += extra;
			numEnd[cPow] = extra;
			numRem[cPow] += pOf2Cnt[cPow] - numCmp;
		}

		int cRem = numRem[0];

		for (int cEnd = 0; cEnd <= 40; cEnd++) {
			cRem += numRem[cEnd + 1];
			int sub = Math.min(numEnd[cEnd], cRem);
			cRem -= sub;
		}
		return cRem == 0;
	}

}
