// package codeforces.cf4xx.cf412.div1;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;

public class C {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        Map<Long,Integer> p = new HashMap<>();
        for (int i = 0; i < 50; i++) {
            p.put(1L<<i, i);
        }
        long[] a = in.nextLongs(n);
        int[] powCnt = new int[42];
        int[] between = new int[42];
        for (int i = 0; i < a.length; i++) {
            if (p.containsKey(a[i])) {
                powCnt[p.get(a[i])]++;
            } else {
                for (int l = 0 ; l < 41 ; l++) {
                    if ((1L<<l) < a[i] && a[i] < (1L<<(l+1))) {
                        between[l]++;
                        break;
                    }
                }
            }
        }

        int[] heights = new int[42];
        while (powCnt[0] >= 1) {
            for (int i = 0 ; i < 41 ; i++) {
                if (powCnt[i] >= 1) {
                    powCnt[i]--;
                } else {
                    heights[i-1]++;
                    break;
                }
            }
        }
        for (int i = 0 ; i < 41 ; i++) {
            between[i] += powCnt[i];
        }

        assert between[0] == 0;

        int ok = 0;
        int ng = n + 100;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            if (doit(heights.clone(), between.clone(), med) >= 0) {
                ok = med;
            } else {
                ng = med;
            }
        }

        int maxCount = doit(heights.clone(), between.clone(), 0);
        int minCount = doit(heights.clone(), between.clone(), ok);
        if (maxCount == -1) {
            out.println(-1);
        } else {
            StringBuilder line = new StringBuilder();
            for (int m = minCount ; m <= maxCount; m++) {
                line.append(' ').append(m);
            }
            out.println(line.substring(1));
        }

        out.flush();
    }

    private static int doit(int[] heights, int[] between, int dec) {
        for (int d = 0 ; d < heights.length ; d++) {
            if (heights[d] >= 1) {
                int de = Math.min(dec, heights[d]);
                heights[d] -= de;
                between[d] += de;
                dec -= de;
            }
        }
        if (dec >= 1) {
            return -1;
        }

        int hoge = 0;
        for (int i = 0 ; i < heights.length ; i++) {
            hoge += heights[i];
        }

        for (int i = 0 ; i < 41 ; i++) {
            int have = between[i];
            for (int j = i ; j < 41 ; j++) {
                if (heights[j] >= 1) {
                    int de = Math.min(heights[j], have);
                    have -= de;
                    heights[j] -= de;
                }
            }
            if (have >= 1) {
                return -1;
            }
        }
        return hoge;
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int[] nextInts(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

        private int[][] nextIntTable(int n, int m) {
            int[][] ret = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    ret[i][j] = nextInt();
                }
            }
            return ret;
        }

        private long[] nextLongs(int n) {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        private long[][] nextLongTable(int n, int m) {
            long[][] ret = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    ret[i][j] = nextLong();
                }
            }
            return ret;
        }

        private double[] nextDoubles(int n) {
            double[] ret = new double[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextDouble();
            }
            return ret;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


// package codeforces.cf4xx.cf412.div1;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;

public class C {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        Map<Long,Integer> p = new HashMap<>();
        for (int i = 0; i < 50; i++) {
            p.put(1L<<i, i);
        }
        long[] a = in.nextLongs(n);
        int[] powCnt = new int[42];
        int[] between = new int[42];
        for (int i = 0; i < a.length; i++) {
            if (p.containsKey(a[i])) {
                powCnt[p.get(a[i])]++;
            } else {
                for (int l = 0 ; l < 41 ; l++) {
                    if ((1L<<l) < a[i] && a[i] < (1L<<(l+1))) {
                        between[l]++;
                        break;
                    }
                }
            }
        }

        int[] heights = new int[42];
        while (powCnt[0] >= 1) {
            for (int i = 0 ; i < 41 ; i++) {
                if (powCnt[i] >= 1) {
                    powCnt[i]--;
                } else {
                    heights[i-1]++;
                    break;
                }
            }
        }
        for (int i = 0 ; i < 41 ; i++) {
            between[i] += powCnt[i];
        }

        assert between[0] == 0;

        int ok = 0;
        int ng = n + 100;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            if (doit(heights.clone(), between.clone(), med) >= 0) {
                ok = med;
            } else {
                ng = med;
            }
        }

        int maxCount = doit(heights.clone(), between.clone(), 0);
        int minCount = doit(heights.clone(), between.clone(), ok);
        if (maxCount == -1) {
            out.println(-1);
        } else {
            StringBuilder line = new StringBuilder();
            for (int m = minCount ; m <= maxCount; m++) {
                line.append(' ').append(m);
            }
            out.println(line.substring(1));
        }
        out.flush();
    }

    private static int doit(int[] heights, int[] between, int dec) {
        for (int d = 0 ; d < heights.length ; d++) {
            if (heights[d] >= 1) {
                int de = Math.min(dec / (d+1), heights[d]);
                heights[d] -= de;
                for (int x = 0 ; x <= d ; x++) {
                    between[x] += de;
                }
                dec -= de * (d+1);

                if (heights[d] >= 1 && dec >= 1) {
                    heights[d]--;
                    int lastX = 1;
                    for (int x = d ; x >= 0 && dec >= 1 ; x--) {
                        dec--;
                        between[x]++;
                        lastX = x;
                    }
                    if (lastX >= 1) {
                        heights[lastX-1]++;
                    }
                }
            }
        }
        if (dec >= 1) {
            return -1;
        }

        int hoge = 0;
        for (int i = 0 ; i < heights.length ; i++) {
            hoge += heights[i];
        }

        for (int i = 0 ; i < 41 ; i++) {
            int have = between[i];
            for (int j = i ; j < 41 ; j++) {
                if (heights[j] >= 1) {
                    int de = Math.min(heights[j], have);
                    have -= de;
                    heights[j] -= de;
                }
            }
            if (have >= 1) {
                return -1;
            }
        }
        return hoge;
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int[] nextInts(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

        private int[][] nextIntTable(int n, int m) {
            int[][] ret = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    ret[i][j] = nextInt();
                }
            }
            return ret;
        }

        private long[] nextLongs(int n) {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        private long[][] nextLongTable(int n, int m) {
            long[][] ret = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    ret[i][j] = nextLong();
                }
            }
            return ret;
        }

        private double[] nextDoubles(int n) {
            double[] ret = new double[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextDouble();
            }
            return ret;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


//package round412;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		long[] a = new long[n];
		for(int i = 0;i < n;i++){
			a[i] = nl();
		}
		int[] fx = new int[50];
		for(int i = 0;i < n;i++){
			if((a[i]&a[i]-1) == 0){
				fx[Long.numberOfTrailingZeros(a[i])]++;
			}
		}
		int[] free = new int[50];
		int nf = 0;
		for(int i = 0;i < n;i++){
			if((a[i]&a[i]-1) != 0){
				int b = Long.numberOfTrailingZeros(Long.highestOneBit(a[i]));
				for(int j = 0;j <= b;j++){
					fx[j]--;
				}
				free[b+1]++;
				nf++;
			}
		}
		for(int i = 0;i < 50;i++){
			if(fx[i] < 0){
				out.println(-1);
				return;
			}
		}

		List<Integer> ret = new ArrayList<>();

		outer:
		for(int k = 0;k <= fx[0];k++){
			int grow = k;
			int binded = 0;
			for(int d = 0;d < 50;d++){
				binded += free[d];
				if(grow >= fx[d]){
					grow = fx[d];
					binded = 0;
				}else if(grow + binded >= fx[d]){
					binded = fx[d] - grow;
				}else{
					int ex = fx[d] - grow - binded;
					grow -= ex;
					binded += ex;
					if(grow < 0){
						continue outer;
					}
				}
			}
			ret.add(nf + k);
		}
		if(ret.isEmpty()){
			out.println(-1);
			return;
		}
		for(int v : ret){
			out.print(v + " ");
		}
	}

	void run() throws Exception
	{
//		int n = 100000, m = 99999;
//		Random gen = new Random();
//		StringBuilder sb = new StringBuilder();
//		sb.append(n + " ");
//		for (int i = 0; i < n; i++) {
//			sb.append(gen.nextInt(2)+1 + " ");
//		}
//		INPUT = sb.toString();

		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i/2] += fr[i] - toMake;
					}
					else {
						have[i/2] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int SIZE = 100;
		int[] fr = new int[SIZE];
		int[] mins = new int[SIZE];
		int[] made = new int[SIZE];
		int[] have = new int[SIZE];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]-madeSoFar), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int SIZE = 100;
		int[] fr = new int[SIZE];
		int[] mins = new int[SIZE];
		int[] made = new int[SIZE];
		int[] have = new int[SIZE];
		boolean fnd = false;
		int lo = 1, hi = freq[0], res = -1;

		for(int bs = 0; bs < 50 && lo <= hi; bs++) {
			int size = (lo+hi)/2;
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]-madeSoFar), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) {
				lo = size+1;
				continue;
			}

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) {
				lo = size+1;
				continue;
			}
			res = size;
			hi = size-1;
		}

		if(res == -1) {
			out.println(-1);
		}
		else {
			for(int i = res; i <= freq[0]; i++) {
				if(i > res) out.print(" ");
				out.print(i);
			}
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(mins[i], size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}
			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(fr[i], size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				System.out.println(i + " " + j + " M " + made[i]);
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}
			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(fr[i], size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int SIZE = 100;
		int[] fr = new int[SIZE];
		int[] mins = new int[SIZE];
		int[] made = new int[SIZE];
		int[] have = new int[SIZE];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]-madeSoFar), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i/2] += fr[i] - toMake;
					}
					else {
						have[i/2] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class C implements Runnable {
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = fs.nextLong();
		int[] freq = new int[100];
		if(a[0] != 1) {
			System.out.println(-1);
			return;
		}
		int ptr = 0; while(ptr < n && a[ptr] == 1) ptr++;
		freq[0] = ptr;

		int idx = 1;
		long next = 2L, prev = 1L;
		while(next <= (long)1e13) {
			int oPtr = ptr;
			while(ptr < n && a[ptr] > prev && a[ptr] < next) ptr++;
			freq[idx++] = ptr-oPtr;
			oPtr = ptr;
			while(ptr < n && a[ptr] == next) ptr++;
			freq[idx++] = ptr-oPtr;

			next *= 2L;
			prev *= 2L;
		}

		int[] fr = new int[100];
		int[] mins = new int[100];
		int[] made = new int[100];
		int[] have = new int[100];
		boolean fnd = false;
		for(int size = 1; size <= freq[0]; size++) {
			for(int i = 0; i < 100; i++) {
				fr[i] = 0; mins[i] = 0;
				made[i] = 0; have[i] = 0;
			}

			for(int i = 0, j = 0; j < freq.length; i++, j += 2) {
				fr[i] = freq[j];
				mins[i] = fr[i];
				if(i > 0) mins[i] = Math.min(mins[i-1], mins[i]);
			}

			int madeSoFar = 0;
			for(int i = fr.length-1; i >= 0; i--) if(fr[i] != 0) {
				if(fr[i] - madeSoFar >= 0) {
					fr[i] -= madeSoFar;
					if(madeSoFar < size) {
						int toMake = Math.min(Math.min(fr[i], mins[i]), size - madeSoFar);
						made[i] = toMake;
						madeSoFar += made[i];
						if(toMake < fr[i]) have[i/2] += fr[i] - toMake;
					}
					else {
						have[i] += fr[i];
					}
				}
			}
			if(madeSoFar < size) continue;

			for(int i = 1; i < freq.length; i += 2) {
				idx = i / 2;
				have[idx] += freq[i];
			}

			boolean bad = false;
			int j = fr.length-1;
			for(int i = fr.length-1; i >= 0; i--) {
				if(j > i) {
					bad = true;
					break;
				}
				while(j >= 0) {
					if(have[j] == 0) {
						j--; continue;
					}
					int sub = Math.min(have[j], made[i]);
					have[j] -= sub;
					made[i] -= sub;
					if(have[j] == 0) j--;
					if(made[i] == 0) break;
				}
			}
			bad |= j != -1;
			if(bad) continue;
			if(fnd) out.print(" ");
			fnd = true;
			out.print(size);
		}

		if(!fnd) {
			out.println(-1);
		}
		else {
			out.println();
		}

		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            int na = 0;
            int[] p2 = new int[60];
            int[] r2 = new int[60];
            for (int i = 0; i < n; ++i) {
                long x = in.nextLong();
                if ((x & (x - 1)) == 0) {
                    ++p2[Long.numberOfTrailingZeros(x)];
                } else {
                    a[na++] = x;
                }
            }
            n = na;
            a = Arrays.copyOf(a, n);
            Arrays.sort(a);
            int max = p2[0];
            int left = 0;
            int right = max + 1;
            outer:
            while (right - left > 1) {
                int middle = (left + right) / 2;
                r2[0] = middle;
                for (int i = 1; i < r2.length; ++i) {
                    r2[i] = Math.min(p2[i], r2[i - 1]);
                }
                int ptr = a.length - 1;
                int total = 0;
                for (int i = p2.length - 1; i >= 0; --i) {
                    while (ptr >= 0 && a[ptr] >= (1L << i)) {
                        --ptr;
                        ++total;
                    }
                    total += p2[i] - r2[i];
                    if (total > r2[i]) {
                        left = middle;
                        continue outer;
                    }
                }
                right = middle;
            }
            if (right > max) {
                out.println(-1);
            } else {
                out.print(right);
                for (int i = right + 1; i <= max; ++i) {
                    out.print(" ");
                    out.print(i);
                }
                out.println();
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef unsigned long long int  ull;
typedef long long int  ll;
#define FR freopen("input.txt", "r", stdin);
#define FW freopen("output.txt", "w", stdout);
#define SETPRES  std::setprecision(6),std::fixed;
#define pb push_back
#define mp make_pair
#define INF 10000000
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define  Help_me  ios_base::sync_with_stdio(false);
template <class T1>
T1 GCD(T1 A,T1 B)
{
if(B==0)
return A;
else
return GCD(B,A%B);
}
template <class T2>
   T2 mulmod(T2 a,T2 b)  {T2 x=0,y=a%mod;while(b){
           if(b%2==1){x=(x+y)%mod;}
           y=(2*y)%mod;b=b/2;}return x%mod;}
template<class T3>
   T3 power(T3 a,T3 b){T3 x=1,y=a%mod;while(b){if(b%2==1){x=mulmod(x,y)%mod;}y=mulmod(y,y)%mod;b=b/2;}return x%mod;}
template<class T4>
bool cmp(T4 x,T4 y)
{
    return x>y?1:0;
}
int n;
multiset<ll> arr;
vector<int> temp;
int main()
{
Help_me
#ifndef ONLINE_JUDGE
    //string s="646";
    //stringstream(s)>>number;
    FR
//    FW
    #endif
    cin>>n;
    ll x;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==1)
            cnt++;
        arr.insert(x);
    }
    multiset<ll> ::iterator itr;
for(int i=0;i<cnt;i++)
{
    int total=1;
        arr.erase(1);
int    next=2;
    while(1)
    {
        if(arr.find(next)!=arr.end())
        {
            itr=arr.find(next);
            arr.erase(itr);
            next*=2;
        total++;
        }
        else
            break;
    }
 temp.push_back(total);
}
int rs=arr.size();
if(rs>cnt)
{
    cout<<"-1";
    return 0;
}
vector<int> ans;
ans.push_back(cnt);
for(int i=temp.size()-1;i>=0;i--)
{
    rs+=temp[i];
    cnt--;
    if(rs<=cnt)
        ans.push_back(cnt);
    else
        break;
}
for(int i=ans.size()-1;i>=0;i--)
cout<<ans[i]<<" ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef unsigned long long int  ull;
typedef long long int  ll;
#define FR freopen("input.txt", "r", stdin);
#define FW freopen("output.txt", "w", stdout);
#define SETPRES  std::setprecision(6),std::fixed;
#define pb push_back
#define mp make_pair
#define INF 10000000
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define  Help_me  ios_base::sync_with_stdio(false);
template <class T1>
T1 GCD(T1 A,T1 B)
{
if(B==0)
return A;
else
return GCD(B,A%B);
}
template <class T2>
   T2 mulmod(T2 a,T2 b)  {T2 x=0,y=a%mod;while(b){
           if(b%2==1){x=(x+y)%mod;}
           y=(2*y)%mod;b=b/2;}return x%mod;}
template<class T3>
   T3 power(T3 a,T3 b){T3 x=1,y=a%mod;while(b){if(b%2==1){x=mulmod(x,y)%mod;}y=mulmod(y,y)%mod;b=b/2;}return x%mod;}
template<class T4>
bool cmp(T4 x,T4 y)
{
    return x>y?1:0;
}
int n;
multiset<ll> arr;

vector<ll> temp;

bool check(int cnt)
{
    temp.clear();
    multiset<ll> new_arr=arr;
      multiset<ll> ::iterator itr;
for(int i=0;i<cnt;i++)
{
    ll total=1;
         itr=new_arr.find(1);
            new_arr.erase(itr);
ll   next=2;
    while(1)
    {
        if(new_arr.find(next)!=new_arr.end())
        {
            itr=new_arr.find(next);
            new_arr.erase(itr);
            next*=2;
        total++;
        }
        else
            break;
    }
 temp.push_back(next);
}
sort(temp.begin(),temp.end(),greater<ll>());
std::multiset<ll>::reverse_iterator itr1=new_arr.rbegin();
for (int i=0;i<temp.size();i++)
    {
                if(itr1==new_arr.rend())
            break;
        if((*itr1)<=temp[i])
        {
       // /    new_arr.erase(itr1);
            itr1++;
        }
        else
            return false;

    }
    if(itr1!=new_arr.rend())
        return false;
    return true;
}
int main()
{
Help_me
#ifndef ONLINE_JUDGE
    //string s="646";
    //stringstream(s)>>number;
    FR
//    FW
    #endif
    cin>>n;
    ll x;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==1)
            cnt++;
        arr.insert(x);
    }
    if(cnt==0)
    {
        cout<<"-1";
        return 0;
    }
    int lo=1,hi=cnt;
    while(lo<hi)
    {
        int mid=(lo+hi)/2;
        if(check(mid))
        {
            hi=mid;
        }
        else
            lo=mid+1;
    }

//int rs=arr.size();
if(!check(lo))
{
    cout<<"-1";
    return 0;
}

for(int i=lo;i<=cnt;i++)
    cout<<i<<" ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef unsigned long long int  ull;
typedef long long int  ll;
#define FR freopen("input.txt", "r", stdin);
#define FW freopen("output.txt", "w", stdout);
#define SETPRES  std::setprecision(6),std::fixed;
#define pb push_back
#define mp make_pair
#define INF 10000000
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define  Help_me  ios_base::sync_with_stdio(false);
template <class T1>
T1 GCD(T1 A,T1 B)
{
if(B==0)
return A;
else
return GCD(B,A%B);
}
template <class T2>
   T2 mulmod(T2 a,T2 b)  {T2 x=0,y=a%mod;while(b){
           if(b%2==1){x=(x+y)%mod;}
           y=(2*y)%mod;b=b/2;}return x%mod;}
template<class T3>
   T3 power(T3 a,T3 b){T3 x=1,y=a%mod;while(b){if(b%2==1){x=mulmod(x,y)%mod;}y=mulmod(y,y)%mod;b=b/2;}return x%mod;}
template<class T4>
bool cmp(T4 x,T4 y)
{
    return x>y?1:0;
}
int n;
multiset<ll> arr;

vector<ll> temp;

bool check(int cnt)
{
    temp.clear();
    multiset<ll> new_arr=arr;
      multiset<ll> ::iterator itr;
for(int i=0;i<cnt;i++)
{
    ll total=1;
         itr=new_arr.find(1);
            new_arr.erase(itr);
ll   next=2;
    while(1)
    {
        if(new_arr.find(next)!=new_arr.end())
        {
            itr=new_arr.find(next);
            new_arr.erase(itr);
            next*=2;
        total++;
        }
        else
            break;
    }
 temp.push_back(next);
}
sort(temp.begin(),temp.end(),greater<ll>());
std::multiset<ll>::reverse_iterator itr1=new_arr.rbegin();
for (int i=0;i<temp.size();i++)
    {
        if((*itr1)<=temp[i])
        {
       // /    new_arr.erase(itr1);
            itr1++;
        }
        else
            return false;
    }
    if(itr1!=new_arr.rend())
        return false;
    return true;
}
int main()
{
Help_me
#ifndef ONLINE_JUDGE
    //string s="646";
    //stringstream(s)>>number;
    FR
//    FW
    #endif
    cin>>n;
    ll x;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==1)
            cnt++;
        arr.insert(x);
    }
    int lo=1,hi=cnt;
    while(lo<hi)
    {
        int mid=(lo+hi)/2;
        if(check(mid))
        {
            hi=mid;
        }
        else
            lo=mid+1;
    }

//int rs=arr.size();
if(!check(lo))
{
    cout<<"-1";
    return 0;
}

for(int i=lo;i<=cnt;i++)
    cout<<i<<" ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef unsigned long long int  ull;
typedef long long int  ll;
#define FR freopen("input.txt", "r", stdin);
#define FW freopen("output.txt", "w", stdout);
#define SETPRES  std::setprecision(6),std::fixed;
#define pb push_back
#define mp make_pair
#define INF 10000000
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define  Help_me  ios_base::sync_with_stdio(false);
template <class T1>
T1 GCD(T1 A,T1 B)
{
if(B==0)
return A;
else
return GCD(B,A%B);
}
template <class T2>
   T2 mulmod(T2 a,T2 b)  {T2 x=0,y=a%mod;while(b){
           if(b%2==1){x=(x+y)%mod;}
           y=(2*y)%mod;b=b/2;}return x%mod;}
template<class T3>
   T3 power(T3 a,T3 b){T3 x=1,y=a%mod;while(b){if(b%2==1){x=mulmod(x,y)%mod;}y=mulmod(y,y)%mod;b=b/2;}return x%mod;}
template<class T4>
bool cmp(T4 x,T4 y)
{
    return x>y?1:0;
}
int n;
multiset<ll> arr;

vector<ll> temp;

bool check(int cnt)
{
    temp.clear();
    multiset<ll> new_arr=arr;
      multiset<ll> ::iterator itr;
for(int i=0;i<cnt;i++)
{
    ll total=1;
         itr=new_arr.find(1);
            new_arr.erase(itr);
ll   next=2;
    while(1)
    {
        if(new_arr.find(next)!=new_arr.end())
        {
            itr=new_arr.find(next);
            new_arr.erase(itr);
            next*=2;
        total++;
        }
        else
            break;
    }
 temp.push_back(next);
}
sort(temp.begin(),temp.end(),greater<ll>());
std::multiset<ll>::reverse_iterator itr1=new_arr.rbegin();
for (int i=0;i<temp.size();i++)
    {
        if((*itr1)<=temp[i])
        {
       // /    new_arr.erase(itr1);
            itr1++;
        }
        else
            return false;
        if(itr1==new_arr.rend())
            break;
    }
    if(itr1!=new_arr.rend())
        return false;
    return true;
}
int main()
{
Help_me
#ifndef ONLINE_JUDGE
    //string s="646";
    //stringstream(s)>>number;
    FR
//    FW
    #endif
    cin>>n;
    ll x;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==1)
            cnt++;
        arr.insert(x);
    }
    int lo=1,hi=cnt;
    while(lo<hi)
    {
        int mid=(lo+hi)/2;
        if(check(mid))
        {
            hi=mid;
        }
        else
            lo=mid+1;
    }

//int rs=arr.size();
if(!check(lo))
{
    cout<<"-1";
    return 0;
}

for(int i=lo;i<=cnt;i++)
    cout<<i<<" ";

    return 0;

}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
using namespace std;

inline ll read() {
	ll s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 60;
inline void Min(int &x,int v) { if( x > v ) x = v; }
inline void Max(int &x,int v) { if( v > x ) x = v; }
int f[N], v[N]; ll x, y;
inline void In(int &num) {
	int now = 0;
	while( f[now] ) f[now++]--;
	now--;
	dow(i,now,0) if( v[i] ) { v[i]--, num--; return; }
	rep(i,0,now) if( f[i] > f[i+1] ) { f[i]--; return; }
}

ll bit[N] = {1};

int main() {
	int n = read(), num = 0;
	rep(i,1,59) bit[i] = bit[i-1] << 1;
	rep(i,1,n) {
		x = read(), y = log2(x);
		if( bit[y] != x ) v[y]++, num++;
		else f[y]++;
	}
	int minl = n;
	rep(i,0,59) {
		int d = max(0,f[i]-minl);
		v[i] += d, num += d, f[i] -= d, Min(minl,f[i]);
	}
	int r = f[0], ans = -1;
	rep(i,1,r) {
		In(num);
		if( !f[0] && !num ) { ans = i; break; }
	}
	if( ans == -1 ) cout<<-1<<endl;
	else { rep(i,ans,r) cout<<i<<" "; cout<<endl; }
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
using namespace std;

inline ll read() {
	ll s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 60;
inline void Min(int &x,int v) { if( x > v ) x = v; }
inline void Max(int &x,int v) { if( v > x ) x = v; }
int f[N], v[N]; ll x, y;
inline void In(int &num) {
	int now = 0;
	while( f[now] ) f[now++]--;
	dow(i,now,0) if( v[i] ) { v[i]--, num--; return; }
	rep(i,0,now-1) if( f[i] > f[i+1] ) { f[i]--; return; }
}

int main() {
	int n = read(), l = 0;
	rep(i,1,n) {
		x = read(), y = log2(x);
		if( (1ll << y) != x ) v[y]++, l++;
		else f[y]++;
	}
	int minl = n;
	rep(i,0,59) {
		int d = max(0,f[i]-minl);
		v[i] += d, l += d, f[i] -= d, Min(minl,f[i]);
	}
	int num = l, r = f[0], ans = -1;
	rep(i,1,r) {
		In(num);
		if( !f[0] && !num ) { ans = i; break; }
	}
	if( ans == -1 ) cout<<-1<<endl;
	else { rep(i,ans,r) cout<<i<<" "; cout<<endl; }
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline long long read(){
	long long x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const long long N=100005;
map<long long,long long> M,ycl;
map<long long,long long>::iterator it;
long long tot,n,ans[N];
long long a[N],bin[60],b[N],mx,mi,tong[60],zs[60];
int main(){
	n=read(); bin[0]=1; ycl[1]=0;
	for(long long i=1;i<60;i++){ycl[bin[i]=bin[i-1]<<1]=i;}
	for(long long i=1;i<=n;i++)if(ycl.find(a[i]=read())!=ycl.end())tong[ycl[a[i]]]++; else b[++tot]=a[i]; mx=tong[0];
	sort(&b[1],&b[tot+1]);
	for(long long i=tot;i;i--){
		int j=59;
		for(;!tong[j]&&j;j--);
		if(bin[j]*2<b[i]){
			puts("-1"); return 0;
		}
	    for(int i=j;i>=0;i--)if(!tong[i]){
	    	puts("-1"); return 0;
		}else tong[i]--;
	    ans[++mi]=j;
	}
	for(int i=0;i<60;i++)zs[i]=tong[i];
	int l=0,r=n+1;
	while(l<r){
		for(int i=0;i<60;i++)tong[i]=zs[i];
		//for(int i=0;i<60;i++)if(tong[i])cout<<i<<" "<<tong[i]<<endl;
		int mid=(l+r)>>1,flag=0;
		for(int i=1;i<=mid;i++){
			ans[i]=0;
			for(int j=0;tong[j];j++)tong[ans[i]=j]--;
		}
		for(int i=1;i<=mid;i++){
			for(int j=ans[i]+1;j>=0;j--)if(tong[j]){
				tong[j]--; break;
			}
		}
		for(int i=0;i<60;i++)if(tong[i]){
			flag=1; break;
		}
		if(!flag)r=mid; else l=mid+1;
	}
	if(l+mi>mx)puts("-1"); else
	for(long long i=l+mi;i<=mx;i++){
		write(i); putchar(' ');
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline long long read(){
	long long x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const long long N=100005;
map<long long,long long> M,ycl;
map<long long,long long>::iterator it;
long long tot,n,ans[N];
long long a[N],bin[60],b[N],mx,mi,tong[60],zs[60];
int main(){
	n=read(); bin[0]=1; ycl[1]=0;
	for(long long i=1;i<60;i++){ycl[bin[i]=bin[i-1]<<1]=i;}
	for(long long i=1;i<=n;i++)if(ycl.find(a[i]=read())!=ycl.end())tong[ycl[a[i]]]++; else b[++tot]=a[i]; mx=tong[0];
	sort(&b[1],&b[tot+1]);
	for(long long i=tot;i;i--){
		int j=59;
		for(;!tong[j]||bin[j+1]<b[i];j--);
	    for(int i=j;i>=0;i--)if(!tong[i]){
	    	puts("-1"); return 0;
		}else tong[i]--;
	    ans[++mi]=j;
	}
	for(int i=0;i<60;i++)zs[i]=tong[i];
	int l=0,r=n+1;
	while(l<r){
		for(int i=0;i<60;i++)tong[i]=zs[i];
		//for(int i=0;i<60;i++)if(tong[i])cout<<i<<" "<<tong[i]<<endl;
		int mid=(l+r)>>1,flag=0;
		for(int i=1;i<=mid;i++){
			ans[i]=0;
			for(int j=0;tong[j];j++)tong[ans[i]=j]--;
		}
		for(int i=1;i<=mid;i++){
			for(int j=ans[i]+1;j>=0;j--)if(tong[j]){
				tong[j]--; break;
			}
		}
		for(int i=0;i<60;i++)if(tong[i]){
			flag=1; break;
		}
		if(!flag)r=mid; else l=mid+1;
	}
	if(l+mi>mx)puts("-1"); else
	for(long long i=l+mi;i<=mx;i++){
		write(i); putchar(' ');
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline long long read(){
	long long x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const long long N=100005;
map<long long,long long> M,ycl;
map<long long,long long>::iterator it;
long long tot,n,ans[N];
long long a[N],bin[60],b[N],mx,mi,tong[60];
int main(){
	n=read(); bin[0]=1; ycl[1]=0;
	for(long long i=1;i<60;i++){ycl[bin[i]=bin[i-1]<<1]=i;}
	for(long long i=1;i<=n;i++)if(ycl.find(a[i]=read())!=ycl.end())tong[ycl[a[i]]]++; else b[++tot]=a[i]; mx=tong[0];
	sort(&b[1],&b[tot+1]);
	for(long long i=tot;i;i--){
		int j=59;
		for(;!tong[j];j--);
	    for(int i=j;i>=0;i--)if(!tong[i]){
	    	puts("-1"); return 0;
		}else tong[i]--;
	    ans[++mi]=j;
	}
	int t=mi;
	for(int i=59;i>=0;i--){
		while(tong[i]){
			for(int j=i;j>=0;j--)if(!tong[j]){
				puts("-1"); return 0;
			}else tong[j]--;
		}
	}
	int l=1,r=n;
	while(l<r){
		for(long long i=1;i<=n;i++)if(ycl.find(a[i])!=ycl.end()){tong[ycl[a[i]]]++;}
		int mid=(l+r)>>1,flag=0;
		for(int i=1;i<=mid;i++){
			for(int j=59;j>=0;j--)if(tong[j]){
				for(int k=j;k>=0;k--)if(!tong[k]){
					puts("-1"); return 0;
				}else tong[k]--;
				ans[i]=j;
				break;
			}
		}
		for(int i=1;i<=mid;i++){
			for(int j=ans[i];j>=0;j--)if(tong[j]){
				tong[j]--; break;
			}
		}
		for(int i=0;i<60;i++)if(tong[i]){
			flag=1; break;
		}
		if(!flag)r=mid; else l=mid+1;
	}
	for(long long i=l;i<=mx;i++){
		write(i); putchar(' ');
	}
}


#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int dat[100];
int rem[100];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%I64d", &z);
		int t = -1;
		for (int j = 0; j < 50; j++)if (z == (1LL << j))t = j;
		if (t != -1)dat[t]++;
		else
		{
			for (int j = 0; j < 50; j++)if ((1LL << j) <= z)t = j;
			rem[t]++;
		}
	}
	for (int i = 0; i < 50; i++)if (dat[i] < dat[i + 1])rem[i] += dat[i + 1] - dat[i], dat[i + 1] = dat[i];
	vector<int>ans;
	for (int i = 1; i <= num; i++)
	{
		if (dat[0] < i)continue;
		int c = 0;
		for (int j = 0; j < 50; j++)
		{
			c += rem[j] + max(0, dat[j] - i);
			c = max(0, c - (min(dat[j], i) - min(dat[j + 1], i)));
		}
		if (c == 0)ans.push_back(i);
	}
	if (ans.empty())printf("-1\n");
	else
	{
		for (int i = 0; i < ans.size(); i++)printf("%d ", ans[i]);
		printf("\n");
	}
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = 2e5;

ll a[maxn];
int n;
int end[maxn];
bool ok[maxn];

bool possible(int k) {
	for (int i = 1; i <= n; i++) { end[i] = 0; ok[i] = true; }
	for (int i = 1; i <= k; i++) { ok[i] = false; }
	end[0] = k;

	ll now = 1;

	for (int i = k+1; i <= n; i++) {
		if (a[i] < 1ll<<now) continue;
		if (a[i] > 1ll<<now) { now++; }
		if (a[i] != 1ll<<now) continue;
		if (end[now-1] == 0) continue;
		ok[i] = false;
		end[now]++; end[now-1]--;
	}

	int m = now+2;

	for (int i = 1; i <= n; i++) {

		if (!ok[i]) continue;

		bool done = false;

		for (ll j = 0; j < m; j++) {
			if (end[j] > 0 && 1ll<<(j+1) >= a[i]) {
				end[j]--;
				ok[i] = false;
				done = true; break;
			}
		}

		if (!done) return false;
	}

	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n; int rgt = 0;

	for (int i = 1; i <= n; i++) {
		cin>>a[i]; if (a[i] == 1) rgt++;
	}

	/*while (true) {
		int k;
		cin>>k;
		possible(k);
		for (int i = 0; i < 14; i++) {
			cout<<end[i]<<" ";
		}
		cout<<endl<<endl;
	}*/

	int l = 1, r = rgt;

	while (l < r) {
		int mid = (l+r-1)>>1;

		if (possible(mid)) {
			r = mid;
		} else { l = mid + 1; }
	}

	if (!possible(l)) { cout<<-1<<endl; return 0; }

	for (int i = l; i <= rgt; i++) {
		cout<<i<<" ";
	}
	cout<<endl;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = 2e5;

ll a[maxn];
int n;
int end[maxn];
bool ok[maxn];

bool possible(int k) {
	for (int i = 1; i <= n; i++) { end[i] = 0; ok[i] = true; }
	for (int i = 1; i <= k; i++) { ok[i] = false; }
	end[0] = k;

	ll now = 1;

	for (int i = k+1; i <= n; i++) {
		if (a[i] < 1ll<<now) continue;
		if (a[i] > 1ll<<now) { now++; }
		if (a[i] != 1ll<<now) continue;
		if (end[now-1] == 0) continue;
		ok[i] = false;
		end[now]++; end[now-1]--;
	}

	int m = now+2;

	for (int i = 1; i <= n; i++) {

		if (!ok[i]) continue;

		bool done = false;

		for (ll j = 0; j < m; j++) {
			if (end[j] > 0 && 1ll<<(j+1) >= a[i]) {
				end[j]--;
				ok[i] = false;
				done = true; break;
			}
		}

		if (!done) return false;
	}

	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n; int rgt = 0;

	for (int i = 1; i <= n; i++) {
		cin>>a[i]; if (a[i] == 1) rgt++;
	}

	int l = 1, r = rgt;

	while (l < r) {
		int mid = (l+r-1)>>1;

		if (possible(mid)) {
			r = mid;
		} else { l = mid + 1; }
	}

	if (!possible(l)) { cout<<-1<<endl; return 0; }

	for (int i = l; i <= rgt; i++) {
		cout<<i<<" ";
	}
	cout<<endl;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = 2e5;
ll a[maxn];
multiset<ll> M;
int n;
int end[maxn];
bool ok[maxn];

bool possible(int k) {
	for (int i = 1; i <= n; i++) { end[i] = 0; ok[i] = true; }
	for (int i = 1; i <= k; i++) { ok[i] = false; }
	end[0] = k;

	int now = 1;

	for (int i = k+1; i <= n; i++) {
		if (a[i] < 1<<now) continue;
		if (a[i] > 1<<now) { now++; }
		if (a[i] != 1<<now) continue;
		if (end[now-1] == 0) continue;
		ok[i] = false;
		end[now]++; end[now-1]--;
	}

	int m = now+2;

	for (int i = 1; i <= n; i++) {

		if (!ok[i]) continue;

		bool done = false;

		for (int j = 0; j < m; j++) {
			if (end[j] > 0 && 1<<(j+1) >= a[i]) {
				end[j]--;
				ok[i] = false;
				done = true; break;
			}
		}

		if (!done) return false;
	}

	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n; M.clear();

	for (int i = 1; i <= n; i++) {
		cin>>a[i]; M.insert(a[i]);
	}

	/*while (true) {
		int k;
		cin>>k;
		possible(k);
		for (int i = 0; i < 14; i++) {
			cout<<end[i]<<" ";
		}
		cout<<endl<<endl;
	}*/

	int rgt = M.count(1);

	int l = 1, r = rgt;

	while (l < r) {
		int mid = (l+r-1)>>1;

		if (possible(mid)) {
			r = mid;
		} else { l = mid + 1; }
	}

	if (!possible(l)) { cout<<-1<<endl; return 0; }

	for (int i = l; i <= rgt; i++) {
		cout<<i<<" ";
	}
	cout<<endl;
}


#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = 2e5;

ll a[maxn];
int n;
int end[maxn];
bool ok[maxn];

bool possible(int k) {

	for (int i = 1; i <= n; i++) { end[i] = 0; ok[i] = true; }
	for (int i = 1; i <= k; i++) { ok[i] = false; }
	end[0] = k;

	ll now = 1;

	for (int i = k+1; i <= n; i++) {
		if (a[i] < 1ll<<now) continue;
		if (a[i] > 1ll<<now) { now++; }
		if (a[i] != 1ll<<now) continue;
		if (end[now-1] == 0) continue;
		ok[i] = false;
		end[now]++; end[now-1]--;
	}

	int m = now+2;

	for (int i = 1; i <= n; i++) {

		if (!ok[i]) continue;

		bool done = false;

		for (ll j = 0; j < m; j++) {
			if (end[j] > 0 && 1ll<<(j+1) >= a[i]) {
				end[j]--;
				ok[i] = false;
				done = true; break;
			}
		}

		if (!done) return false;
	}

	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n; int rgt = 0;

	for (int i = 1; i <= n; i++) {
		cin>>a[i]; if (a[i] == 1) rgt++;
	}

	int l = 1, r = rgt;
	if (l > r) { cout<<-1<<endl; return 0; }

	while (l < r) {
		int mid = (l+r-1)>>1;

		if (possible(mid)) {
			r = mid;
		} else { l = mid + 1; }
	}

	if (!possible(l)) { cout<<-1<<endl; return 0; }

	for (int i = l; i <= rgt; i++) {
		cout<<i<<" ";
	}
	cout<<endl;
}


//   Author:Arturia
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#include<vector>
#define rep(x,a,b) for (int x=a;x<=(int)(b);x++)
#define drp(x,a,b) for (int x=a;x>=(int)(b);x--)
#define cross(x,a) for (int x=hd[a];~x;x=nx[x])
#define ll long long
#define inf (1<<29)
#define pii pair<int,int>
#define pdd pair<double,double>
#define mk(a,b) make_pair(a,b)
#define fs first
#define sc second
#define pb push_back
#define VI vector<int>
#define VS vector<string>
using namespace std;
inline ll rd(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void rt(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) rt(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
const int maxn=100005;
int num[50],mst[50];
int va[50],vb[50],hs[50];
ll pw[50];
int check(int need){
	memcpy(num,va,sizeof num),memcpy(mst,vb,sizeof mst);
	memset(hs,0,sizeof hs);
	while (need){
		if (!num[0]) return 2;
		int nw=0,mn=num[0];
		while (num[nw+1]) nw++,mn=min(mn,num[nw]);
		mn=min(mn,need);
		rep(i,0,nw) num[i]-=mn;hs[nw]+=mn;need-=mn;
	}
	int sum=0;
	drp(i,42,0){
		sum+=hs[i];
		sum-=mst[i+1]+num[i+1];
		if (sum<0) return 0;
	}
	sum-=num[0];
	if (sum<0) return 0;
	return 1;
}
int n;
int main(){
	pw[0]=1;rep(i,1,42) pw[i]=pw[i-1]<<1;
	n=rd();
	rep(i,1,n){
		ll x=rd();
		int y=lower_bound(pw,pw+43,x)-pw;
		if (pw[y]==x) num[y]++;else mst[y]++;
	}
	memcpy(va,num,sizeof num),memcpy(vb,mst,sizeof mst);
	int flg=0;
	rep(i,1,n){
		int t=check(i);
		if (t==2) break;
		else if (t==1) rt(i),putchar(' '),flg=1;
	}
	if (!flg) puts("-1");
}


//   Author:Arturia
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<string>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#include<bitset>
#include<vector>
#define rep(x,a,b) for (int x=a;x<=(int)(b);x++)
#define drp(x,a,b) for (int x=a;x>=(int)(b);x--)
#define cross(x,a) for (int x=hd[a];~x;x=nx[x])
#define ll long long
#define inf (1<<29)
#define pii pair<int,int>
#define pdd pair<double,double>
#define mk(a,b) make_pair(a,b)
#define fs first
#define sc second
#define pb push_back
#define VI vector<int>
#define VS vector<string>
using namespace std;
inline ll rd(){
	ll x=0;int ch=getchar(),f=1;
	while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();
	if (ch=='-'){f=-1;ch=getchar();}
	while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
inline void rt(ll x){
	if (x<0) putchar('-'),x=-x;
	if (x>=10) rt(x/10),putchar(x%10+'0');
		else putchar(x+'0');
}
const int maxn=100005;
int num[50],mst[50];
int va[50],vb[50],hs[50];
ll pw[50];
int check(int need){
	memcpy(num,va,sizeof num),memcpy(mst,vb,sizeof mst);
	memset(hs,0,sizeof hs);
	while (need){
		if (!num[0]) return 2;
		int nw=0,mn=num[0];
		while (num[nw+1]) nw++,mn=min(mn,num[nw]);
		mn=min(mn,need);
		rep(i,0,nw) num[i]-=mn;hs[nw]+=mn;need-=mn;
	}
	int sum=0;
	drp(i,42,0){
		sum+=hs[i];
		sum-=mst[i+1]+num[i+1];
		if (sum<0) return 0;
	}
	return 1;
}
int n;
int main(){
	pw[0]=1;rep(i,1,42) pw[i]=pw[i-1]<<1;
	n=rd();
	rep(i,1,n){
		ll x=rd();
		int y=lower_bound(pw,pw+43,x)-pw;
		if (pw[y]==x) num[y]++;else mst[y]++;
	}
	memcpy(va,num,sizeof num),memcpy(vb,mst,sizeof mst);
	int flg=0;
	rep(i,1,n){
		int t=check(i);
		if (t==2) break;
		else if (t==1) rt(i),putchar(' '),flg=1;
	}
	if (!flg) puts("-1");
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int MAXN = 100005, MAXV = 65;

int n, cur[MAXV], ncur[MAXV], cnt[MAXV], ncnt[MAXV]; LL a[MAXN];

inline bool check(int x){
	int i;
	memset(cur, 0, sizeof(cur));
	memcpy(ncur, ncnt, sizeof(ncur));
	cur[0] = x, ncur[0] = cnt[0] - cur[0];
	for(i = 1; i < 40; ++ i){
		ncur[i] += max(cnt[i] - cur[i - 1], 0);
		cur[i] = min(cur[i - 1], cnt[i]);
	}
	for(i = 39; i >= 0; -- i){
		ncur[i] += ncur[i + 1];
		if(ncur[i] > cur[i]) return false;
	} return true;
}
int main(){
	int i, j, l, r, mid;
	scanf("%d", &n);
	for(i = 1; i <= n; ++ i)
		scanf("%I64d", &a[i]);
	for(i = 1, j = 0; i <= n; ++ i){
		while((1LL << j) < a[i]) ++ j;
		if((1LL << j) == a[i]) ++ cnt[j];
		else ++ ncnt[j - 1];
	} l = 1, r = cnt[0];
	if(!cnt[0]){
		printf("-1\n");
		return 0;
	}
	while(l < r){
		mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	} if(!check(l)) printf("-1\n");
	else for(i = l; i <= cnt[0]; ++ i)
		printf("%d ", i);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int MAXN = 100005, MAXV = 65;

int n, cur[MAXV], ncur[MAXV], cnt[MAXV], ncnt[MAXV]; LL a[MAXN];

inline bool check(int x){
	int i;
	memset(cur, 0, sizeof(cur));
	memcpy(ncur, ncnt, sizeof(ncur));
	cur[0] = x, ncur[0] = cnt[0] - cur[0];
	for(i = 1; i < 40; ++ i){
		ncur[i] += max(cnt[i] - cur[i - 1], 0);
		cur[i] = min(cur[i - 1], cnt[i]);
	}
	for(i = 39; i >= 0; -- i){
		ncur[i] += ncur[i + 1];
		if(ncur[i] > cur[i]) return false;
	} return true;
}
int main(){
	int i, j, l, r, mid;
	scanf("%d", &n);
	for(i = 1; i <= n; ++ i)
		scanf("%I64d", &a[i]);
	for(i = 1, j = 0; i <= n; ++ i){
		while((1LL << j) < a[i]) ++ j;
		if((1LL << j) == a[i]) ++ cnt[j];
		else ++ ncnt[j - 1];
	} l = 1, r = cnt[0];
	while(l < r){
		mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	} if(!check(l)) printf("-1\n");
	else for(i = l; i <= cnt[0]; ++ i)
		printf("%d ", i);
	return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100005;
long long a[maxn], res;
int up, n, m, i, j, k, l, r, ans, cnt[51], len, down, b[51];
bool ok[maxn];

inline long long get()
{
	char c;
	while ((c = getchar()) < 48 || c > 57);
	long long res = c - 48;
	while ((c = getchar()) >= 48 && c <= 57)
		res = res * 10 + c - 48;
	return res;
}
inline bool check(int mid)
{
	int t = cnt[0] - mid;
	for(int i = 1; i <= 50; i ++)
	{
		if (mid >= cnt[i])
		{
			t -= min(t, mid - cnt[i]);
			mid = cnt[i];
		}
		else t += cnt[i] - mid;
		t += b[i];
	}
	return t <= mid;
}
int main()
{
	cin >> n;
	for(i = 1; i <= n; i ++)
	{
		a[i] = get();
		res += a[i];
		if (a[i] == 1) cnt[0] ++, ok[i] = 1;
	}
	long long num = 1;
	for(i = 1; i <= 50; i ++)
	{
		num *= 2;
		for(j = 1; j <= n; j ++)
			if (a[j] == num) cnt[i] ++, ok[j] = 1;
	}
	for(i = 1; i <= n; i ++)
		if (!ok[i]) b[(int)log2(a[i])] ++;
	if (!check(l)) {puts("-1"); return 0;}
	l = 1; r = up = cnt[0];
	while (l < r - 1)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	down = (check(l)) ? l : r;
	for(i = down; i <= up; i ++)
		printf("%d ", i);
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100005;
long long a[maxn], res;
int up, n, m, i, j, k, l, r, ans, cnt[51], len, down, b[51];
bool ok[maxn];

inline long long get()
{
	char c;
	while ((c = getchar()) < 48 || c > 57);
	long long res = c - 48;
	while ((c = getchar()) >= 48 && c <= 57)
		res = res * 10 + c - 48;
	return res;
}
inline bool check(int mid)
{
	int t = cnt[0] - mid;
	for(int i = 1; i <= 50; i ++)
	{
		if (mid >= cnt[i])
		{
			t -= min(t, mid - cnt[i]);
			mid = cnt[i];
		}
		else t += cnt[i] - mid;
		t += b[i];
	}
	return t <= mid;
}
int main()
{
	cin >> n;
	for(i = 1; i <= n; i ++)
	{
		a[i] = get();
		res += a[i];
		if (a[i] == 1) cnt[0] ++, ok[i] = 1;
	}
	long long num = 1;
	for(i = 1; i <= 50; i ++)
	{
		num *= 2;
		for(j = 1; j <= n; j ++)
			if (a[j] == num) cnt[i] ++, ok[j] = 1;
	}
	for(i = 1; i <= n; i ++)
		if (!ok[i]) b[(int)log2(a[i])] ++;
	if (!check(cnt[0])) {puts("-1"); return 0;}
	l = 1; r = up = cnt[0];
	while (l < r - 1)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	down = (check(l)) ? l : r;
	for(i = down; i <= up; i ++)
		printf("%d ", i);
}


#include <bits/stdc++.h>
using namespace std;

typedef long long Int;

const int maxn = 111111;
const int maxp = 42;
Int a[maxn], ans[maxn], sp;

Int unit[maxp];

void init(){
	int i;
	a[0] = 1;
	for(i=0; i<maxp; ++i)
		a[i] = 2 * a[i-1];
}

int cnt[maxp];
int unitcnt[maxp];

int isunit(Int x){
	while(x > 0){
		if(x == 1)
			return 1;
		if(x % 2 == 1)
			return 0;
		x /= 2;
	}
	return 0;
}

int getindex(Int n){
	int rnt = 0;
	-- n;
	while(n > 1){
		n /= 2;
		++ rnt;
	}
	return rnt;
}

int getunitindex(Int n){
	int rnt = 0;
	while(n > 1){
		n /= 2;
		++ rnt;
	}
	return rnt;
}

int main(){
	init();
//	freopen("data1.in", "r", stdin);
	int n, i;
	scanf("%d", &n);
	for(i=0; i<n; ++i){
		scanf("%lld", &a[i]);
		++ cnt[getindex(a[i])];
		if(isunit(a[i]))
			++ unitcnt[getunitindex(a[i])];
	}
	for(i=1;i<=unitcnt[0];++i){
		int leftcnt[maxp] = {0};
		int usedcnt[maxp] = {0};
		int j, cur = i;
		for(j=0; j<maxp; ++j) leftcnt[j] = cnt[j];
		for(j=0; j<maxp; ++j){
			int curv = min(cur, unitcnt[j]);
			if(j > 0)
				usedcnt[j-1] = cur - curv;
			if(j <= 1)
				leftcnt[0] -= curv;
			else
				leftcnt[j-1] -= curv;
			cur = curv;
		}
		cur = 0;
		for(j=maxp-1; j>=0; --j){
			cur += leftcnt[j];
			if(cur > usedcnt[j])
				break;
			cur -= usedcnt[j];
		}
		if(j < 0)
			ans[sp++] = i;
	}

	if(sp == 0)
		puts("-1");
	else{
		for(i=0; i<sp; ++i)
			printf("%lld%c", ans[i], " \n"[i==sp-1]);
	}
	return 0;
}
/*
8
1 1 2 2 3 4 5 8
6
1 1 1 2 2 2
5
1 2 4 4 4

13
1 2 4 5
1 2 4 8 2
1 2 4
1
*/


#include <bits/stdc++.h>
using namespace std;

typedef long long Int;

const int maxn = 111111;
const int maxp = 42;
Int a[maxn], ans[maxn], sp;

Int unit[maxp];

void init(){
	int i;
	a[0] = 1;
	for(i=0; i<maxp; ++i)
		a[i] = 2 * a[i-1];
}

int cnt[maxp];
int unitcnt[maxp];

int isunit(Int x){
	while(x > 0){
		if(x == 1)
			return 1;
		if(x % 2 == 1)
			return 0;
		x /= 2;
	}
	return 0;
}

int getindex(Int n){
	int rnt = 0;
	-- n;
	while(n > 1){
		n /= 2;
		++ rnt;
	}
	return rnt;
}

int getunitindex(Int n){
	int rnt = 0;
	while(n > 1){
		n /= 2;
		++ rnt;
	}
	return rnt;
}

int main(){
	init();
	int n, i;
	scanf("%d", &n);
	for(i=0; i<n; ++i){
		scanf("%lld", &a[i]);
		++ cnt[getindex(a[i])];
		if(isunit(a[i]))
			++ unitcnt[getunitindex(a[i])];
	}
	for(i=1;i<=unitcnt[0];++i){
		int leftcnt[maxp] = {0};
		int usedcnt[maxp] = {0};
		int j, cur = i;
		for(j=0; j<maxp; ++j) leftcnt[j] = cnt[j];
		for(j=0; j<maxp; ++j){
			int curv = min(cur, unitcnt[j]);
			if(j > 0)
				usedcnt[j-1] = cur - curv;
			if(j <= 1)
				leftcnt[0] -= curv;
			else
				leftcnt[j-1] -= curv;
			cur = curv;
		}
		cur = 0;
		for(j=maxp-1; j>=0; --j){
			cur += leftcnt[j];
			if(cur > usedcnt[j])
				break;
			cur -= usedcnt[j];
		}
		if(j < 0)
			ans[sp++] = i;
	}

	if(sp == 0)
		puts("-1");
	else{
		for(i=0; i<sp; ++i)
			printf("%d%c", ans[i], " \n"[i==sp-1]);
	}
	return 0;
}
/*
8
1 1 2 2 3 4 5 8
6
1 1 1 2 2 2
5
1 2 4 4 4
*/


#include <bits/stdc++.h>

using namespace std;

#define fr(a,b,c) for(int (a) = (b); (a) < (c); ++(a))
#define rp(a,b) fr(a,0,b)
#define fre(a,b) for(int a = adj[b]; ~a; a = ant[a])
#define cl(a,b) memset((a), (b), sizeof(a))
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)

#define iter(a) __typeof((a).begin())
#define fore(a,b) for(iter(b) a = (b).begin(); a != (b).end(); ++a)

#define st first
#define nd second
#define mp make_pair
#define pb push_back

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector< vi > vii;

const int oo = 0x3f3f3f3f;

#define N 100009

int n, c1[50], c2[50];
//pii a[N];

int logg(ll a) {
	int r = -1;
	while (a) {
		a >>= 1;
		r++;
	}
	return r;
}

bool ispow(ll a) {
	return (a&(a-1)) == 0;
}

bool pode(int x) {
	int q = x, h = c1[0]-x;

	//db(x);
	fr(i, 1, 50) {
		//db(i _ c1[i] _ c2[i]);

		if (q > c1[i]) {
			int d = q - c1[i];
			h = max(0, h-d);
			q -= d;
		} else {
			//db(h);
			h += c1[i]-q;
			//db(h);
		}
		h += c2[i];

		//db(q _ h);
	}

	//db(h _ q);
	if (h > q) return 0;
	return 1;
}

int main() {
	while (sc(n) == 1) {
		cl(c1, 0);
		cl(c2, 0);
		rp(i, n) {
			ll v;
			scanf("%lld", &v);
			int l = logg(v);

			if (ispow(v)) c1[l]++;
			else c2[l]++;
		}

		int mx = c1[0];

		if (!pode(mx)) {
			puts("-1");
			continue;
		}

		int lo = 0;
		for(int p = 20; p >= 0; p--) {
			int add = 1<<p;
			if (lo+p < mx && !pode(lo+p)) lo += p;
		}
		fr(i, lo+1, mx) printf("%d ", i);
		pri(mx);
	//	return 0;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fr(a,b,c) for(int (a) = (b); (a) < (c); ++(a))
#define rp(a,b) fr(a,0,b)
#define fre(a,b) for(int a = adj[b]; ~a; a = ant[a])
#define cl(a,b) memset((a), (b), sizeof(a))
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)

#define iter(a) __typeof((a).begin())
#define fore(a,b) for(iter(b) a = (b).begin(); a != (b).end(); ++a)

#define st first
#define nd second
#define mp make_pair
#define pb push_back

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector< vi > vii;

int n, c1[70], c2[70];

int logg(ll a) {
	int r = -1;
	while (a > 0) {
		a /= 2;
		r++;
	}
	return r;
}

bool ispow(ll a) {
	return (a&(a-1ll)) == 0ll;
}

bool pode(int x) {
	int q = x, h = c1[0]-x;

	fr(i, 1, 70) {
		h += c2[i];

		if (q > c1[i]) {
			int d = q - c1[i];
			h = max(0, h-d);
			q -= d;
		} else {
			h += c1[i]-q;
		}
	}

	return (h <= q);
}

int main() {
	cin >> n;
	{
		cl(c1, 0);
		cl(c2, 0);
		rp(i, n) {
			ll v;
			cin >> v;

			int l = logg(v);

			if (ispow(v)) c1[l]++;
			else c2[l]++;
		}

		int mx = c1[0];
		if (mx == 0 || !pode(mx)) {
			puts("-1");
			return 0;
		}

		int lo = 0;
		for(int p = 25; p >= 0; p--) {
			int add = (1<<p);
			if (lo+add < mx && !pode(lo+add)) lo += add;
		}
		fr(i, lo+1, mx) cout << i << " ";
		cout << mx << "\n";
	}
	return 0;
}