/* in the name of ALLAH, most gracious, most merciful */
#include<algorithm>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cassert>
#include<utility>
#include<limits>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<stack>
#include<ctime>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define     mems(a,b)       memset(a,b,sizeof(a))
#define     IT              iterator
#define     mp              make_pair
#define     pii             pair<I,I>
#define     fs              first
#define     sc              second
#define     pb              push_back
#define     eps             1E-9
#define     all(a)          a.begin(),a.end()
#define     allr(a)         a.rbegin(),a.rend()
#define     MOD             (1000000007)
#define     llInf           (1LL<<62)
#define     iInf            (2123456789)
#define     min_e           *min_element
#define     max_e           *max_element
#define     lsOne(S)        ((S)&(-(S)))
#define     vhas(c,e)       (find(all(c),e) != c.end())
#define     o(i, start, n)          for(int i = start; i < n; i++)
#define     I3              (ll)1000
#define     I4              (ll)10000
#define     I5              (ll)100000
#define     I6              (ll)1000000
#define     I7              (ll)10000000
#define     I8              (ll)100000000
#define     I9              (ll)1000000000
#define     I10             (ll)10000000000
#define     I11             (ll)100000000000
#define     I12             (ll)1000000000000
#define     I13             (ll)10000000000000
#define     I14             (ll)100000000000000
#define     I15             (ll)1000000000000000
#define     I16             (ll)10000000000000000
#define     I17             (ll)100000000000000000
#define     I18             (ll)1000000000000000000
using namespace std;
typedef long long int ll;
typedef unsigned long long  ull;
typedef double dd;
typedef string str;
typedef char ch;
typedef int I;
inline void _(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
void __(){
    #ifndef ONLINE_JUDGE
    cout << endl << "time elsaped : " << (double)clock() / CLOCKS_PER_SEC << " ms" << endl;
    #endif
}
inline void ___(char *i, char *j){ freopen(i, "r", stdin); freopen(j, "w", stdout); }

//input templates
template<class T1> bool tk(T1 &e1){if(cin>>e1)return true;return false;}
template<class T1,class T2> bool tk(T1 &e1,T2 &e2){if(cin>>e1>>e2)return true;return false;}
template<class T1,class T2,class T3> bool tk(T1 &e1,T2 &e2,T3 &e3){if(cin>>e1>>e2>>e3)return true;return false;}
template<class T1,class T2,class T3,class T4> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4){if(cin>>e1>>e2>>e3>>e4)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5){if(cin>>e1>>e2>>e3>>e4>>e5)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5, class T6> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5,T6 &e6){if(cin>>e1>>e2>>e3>>e4>>e5>>e6)return true;return false;}

// output templates
template<class T1> void put(T1 e){cout<<e<<endl;}
template<class T1,class T2> void put(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
template<class T1,class T2,class T3> void put(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void put(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
template<class T1> void putVec(vector<T1>e1){for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;}
template<class T1> void putArr(T1 arr[],I l){for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;}
// end of output

// bug templates
template<class T1> void bug(T1 e){
    #ifndef ONLINE_JUDGE
    cout<<e<<endl;
    #endif
}
template<class T1,class T2> void bug(T1 e1,T2 e2){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<endl;
    #endif
}
template<class T1,class T2,class T3> void bug(T1 e1,T2 e2,T3 e3){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4> void bug(T1 e1,T2 e2,T3 e3,T4 e4){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
    #endif
}
template<class T1> void bugVec(vector<T1>e1){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;
    #endif
}
template<class T1> void bugArr(T1 arr[],I l){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;
    #endif
}
// end of bugs

//bit mask operation
template<typename T> inline bool isOn(T &mask,I pos){return ((mask)&(1<<pos));}
template<typename T> inline void setOff(T &mask,I pos){mask = ((mask)&(~(1<<pos)));}
template<typename T> inline void setOn(T &mask,I pos){mask = ((mask)(1<<pos));}
//end of bit mask operations

namespace gv{

};

long long absolute(long long a){
    if(a < 0) return -a;
    return a;
}

int main(){
    _();

    vector<pair<int, pair<int, int > > > ans(2);
    ans[1] = {2 * I9, {2 * I9 + 1, 2 * I9 + 1}};

    int n, m, c; vector<int > a, b;
    tk(n); o(i, 0, n) tk(c), a.push_back(c); sort(all(a));
    tk(m); o(i, 0, m) tk(c), b.push_back(c); sort(all(b));

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

        for(int j = -1; j < 1; j++){

        int lo = max(a[i] + j, 0);

        int binaryLo = 0, binaryHi = a.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        bug(A, B, lo, binaryLo);

        ans[0] = {-1 * A + B, {-1 * A, B}};
        sort(all(ans));
        }
    }

    for(int i = 0; i < m; i++){

        for(int j = -1; j < 1; j++){

        int lo = max(b[i] + j, 0);

        int binaryLo = 0, binaryHi = a.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        bug(A, B, lo, binaryLo);

        ans[0] = {-1 * A + B, {-1 * A, B}};
        sort(all(ans));

        }
    }

    cout << (-1 * (ans[0].second.first)) << ":" << ans[0].second.second << endl;

    __();
}


/* in the name of ALLAH, most gracious, most merciful */
#include<algorithm>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cassert>
#include<utility>
#include<limits>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<stack>
#include<ctime>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define     mems(a,b)       memset(a,b,sizeof(a))
#define     IT              iterator
#define     mp              make_pair
#define     pii             pair<I,I>
#define     fs              first
#define     sc              second
#define     pb              push_back
#define     eps             1E-9
#define     all(a)          a.begin(),a.end()
#define     allr(a)         a.rbegin(),a.rend()
#define     MOD             (1000000007)
#define     llInf           (1LL<<62)
#define     iInf            (2123456789)
#define     min_e           *min_element
#define     max_e           *max_element
#define     lsOne(S)        ((S)&(-(S)))
#define     vhas(c,e)       (find(all(c),e) != c.end())
#define     o(i, start, n)          for(int i = start; i < n; i++)
#define     I3              (ll)1000
#define     I4              (ll)10000
#define     I5              (ll)100000
#define     I6              (ll)1000000
#define     I7              (ll)10000000
#define     I8              (ll)100000000
#define     I9              (ll)1000000000
#define     I10             (ll)10000000000
#define     I11             (ll)100000000000
#define     I12             (ll)1000000000000
#define     I13             (ll)10000000000000
#define     I14             (ll)100000000000000
#define     I15             (ll)1000000000000000
#define     I16             (ll)10000000000000000
#define     I17             (ll)100000000000000000
#define     I18             (ll)1000000000000000000
using namespace std;
typedef long long int ll;
typedef unsigned long long  ull;
typedef double dd;
typedef string str;
typedef char ch;
typedef int I;
inline void _(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
void __(){
    #ifndef ONLINE_JUDGE
    cout << endl << "time elsaped : " << (double)clock() / CLOCKS_PER_SEC << " ms" << endl;
    #endif
}
inline void ___(char *i, char *j){ freopen(i, "r", stdin); freopen(j, "w", stdout); }

//input templates
template<class T1> bool tk(T1 &e1){if(cin>>e1)return true;return false;}
template<class T1,class T2> bool tk(T1 &e1,T2 &e2){if(cin>>e1>>e2)return true;return false;}
template<class T1,class T2,class T3> bool tk(T1 &e1,T2 &e2,T3 &e3){if(cin>>e1>>e2>>e3)return true;return false;}
template<class T1,class T2,class T3,class T4> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4){if(cin>>e1>>e2>>e3>>e4)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5){if(cin>>e1>>e2>>e3>>e4>>e5)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5, class T6> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5,T6 &e6){if(cin>>e1>>e2>>e3>>e4>>e5>>e6)return true;return false;}

// output templates
template<class T1> void put(T1 e){cout<<e<<endl;}
template<class T1,class T2> void put(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
template<class T1,class T2,class T3> void put(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void put(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
template<class T1> void putVec(vector<T1>e1){for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;}
template<class T1> void putArr(T1 arr[],I l){for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;}
// end of output

// bug templates
template<class T1> void bug(T1 e){
    #ifndef ONLINE_JUDGE
    cout<<e<<endl;
    #endif
}
template<class T1,class T2> void bug(T1 e1,T2 e2){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<endl;
    #endif
}
template<class T1,class T2,class T3> void bug(T1 e1,T2 e2,T3 e3){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4> void bug(T1 e1,T2 e2,T3 e3,T4 e4){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
    #endif
}
template<class T1> void bugVec(vector<T1>e1){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;
    #endif
}
template<class T1> void bugArr(T1 arr[],I l){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;
    #endif
}
// end of bugs

//bit mask operation
template<typename T> inline bool isOn(T &mask,I pos){return ((mask)&(1<<pos));}
template<typename T> inline void setOff(T &mask,I pos){mask = ((mask)&(~(1<<pos)));}
template<typename T> inline void setOn(T &mask,I pos){mask = ((mask)(1<<pos));}
//end of bit mask operations

namespace gv{

};

long long absolute(long long a){
    if(a < 0) return -a;
    return a;
}

int main(){
    _();

    vector<pair<int, pair<int, int > > > ans(2);
    ans[0] = {2 * I9, {2 * I9 + 1, 2 * I9 + 1}};

    int n, m, c; vector<int > a, b;
    tk(n); o(i, 0, n) tk(c), a.push_back(c); sort(all(a));
    tk(m); o(i, 0, m) tk(c), b.push_back(c); sort(all(b));

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

        for(int j = -1; j < 1; j++){

        int lo = max(a[i] + j, 0);

        int binaryLo = 0, binaryHi = a.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        bug(A, B, lo, binaryLo);

        ans[1] = {-1 * A + B, {-1 * A, B}};
        sort(all(ans));
        }
    }

    for(int i = 0; i < m; i++){

        for(int j = -1; j < 1; j++){

        int lo = max(b[i] + j, 0);

        int binaryLo = 0, binaryHi = a.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] <= lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }

        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        bug(A, B, lo, binaryLo);

        ans[1] = {-1 * A + B, {-1 * A, B}};
        sort(all(ans));

        }
    }

    cout << (-1 * (ans[0].second.first)) << ":" << ans[0].second.second << endl;

    __();
}


/* in the name of ALLAH, most gracious, most merciful */
#include<algorithm>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cassert>
#include<utility>
#include<limits>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<stack>
#include<ctime>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define     mems(a,b)       memset(a,b,sizeof(a))
#define     IT              iterator
#define     mp              make_pair
#define     pii             pair<I,I>
#define     fs              first
#define     sc              second
#define     pb              push_back
#define     eps             1E-9
#define     all(a)          a.begin(),a.end()
#define     allr(a)         a.rbegin(),a.rend()
#define     MOD             (1000000007)
#define     llInf           (1LL<<62)
#define     iInf            (2123456789)
#define     min_e           *min_element
#define     max_e           *max_element
#define     lsOne(S)        ((S)&(-(S)))
#define     vhas(c,e)       (find(all(c),e) != c.end())
#define     o(i, start, n)          for(int i = start; i < n; i++)
#define     I3              (ll)1000
#define     I4              (ll)10000
#define     I5              (ll)100000
#define     I6              (ll)1000000
#define     I7              (ll)10000000
#define     I8              (ll)100000000
#define     I9              (ll)1000000000
#define     I10             (ll)10000000000
#define     I11             (ll)100000000000
#define     I12             (ll)1000000000000
#define     I13             (ll)10000000000000
#define     I14             (ll)100000000000000
#define     I15             (ll)1000000000000000
#define     I16             (ll)10000000000000000
#define     I17             (ll)100000000000000000
#define     I18             (ll)1000000000000000000
using namespace std;
typedef long long int ll;
typedef unsigned long long  ull;
typedef double dd;
typedef string str;
typedef char ch;
typedef int I;
inline void _(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
void __(){
    #ifndef ONLINE_JUDGE
    cout << endl << "time elsaped : " << (double)clock() / CLOCKS_PER_SEC << " ms" << endl;
    #endif
}
inline void ___(char *i, char *j){ freopen(i, "r", stdin); freopen(j, "w", stdout); }

//input templates
template<class T1> bool tk(T1 &e1){if(cin>>e1)return true;return false;}
template<class T1,class T2> bool tk(T1 &e1,T2 &e2){if(cin>>e1>>e2)return true;return false;}
template<class T1,class T2,class T3> bool tk(T1 &e1,T2 &e2,T3 &e3){if(cin>>e1>>e2>>e3)return true;return false;}
template<class T1,class T2,class T3,class T4> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4){if(cin>>e1>>e2>>e3>>e4)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5){if(cin>>e1>>e2>>e3>>e4>>e5)return true;return false;}
template<class T1,class T2,class T3,class T4,class T5, class T6> bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4,T5 &e5,T6 &e6){if(cin>>e1>>e2>>e3>>e4>>e5>>e6)return true;return false;}

// output templates
template<class T1> void put(T1 e){cout<<e<<endl;}
template<class T1,class T2> void put(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
template<class T1,class T2,class T3> void put(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void put(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
template<class T1> void putVec(vector<T1>e1){for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;}
template<class T1> void putArr(T1 arr[],I l){for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;}
// end of output

// bug templates
template<class T1> void bug(T1 e){
    #ifndef ONLINE_JUDGE
    cout<<e<<endl;
    #endif
}
template<class T1,class T2> void bug(T1 e1,T2 e2){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<endl;
    #endif
}
template<class T1,class T2,class T3> void bug(T1 e1,T2 e2,T3 e3){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4> void bug(T1 e1,T2 e2,T3 e3,T4 e4){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
    #endif
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void bug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){
    #ifndef ONLINE_JUDGE
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
    #endif
}
template<class T1> void bugVec(vector<T1>e1){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<(e1).size(); i++)(!i?cout<<e1[i]:cout<<" "<<e1[i]);cout<<endl;
    #endif
}
template<class T1> void bugArr(T1 arr[],I l){
    #ifndef ONLINE_JUDGE
    for(I i=0; i<l; i++)(!i?cout<<arr[i]:cout<<" "<<arr[i]);cout<<endl;
    #endif
}
// end of bugs

//bit mask operation
template<typename T> inline bool isOn(T &mask,I pos){return ((mask)&(1<<pos));}
template<typename T> inline void setOff(T &mask,I pos){mask = ((mask)&(~(1<<pos)));}
template<typename T> inline void setOn(T &mask,I pos){mask = ((mask)(1<<pos));}
//end of bit mask operations

namespace gv{

};

long long absolute(long long a){
    if(a < 0) return -a;
    return a;
}

int main(){
    _();

    vector<pair<int, pair<int, int > > > ans;

    int n, m, c; vector<int > a, b;
    tk(n); o(i, 0, n) tk(c), a.push_back(c); sort(all(a));
    tk(m); o(i, 0, m) tk(c), b.push_back(c); sort(all(b));

    long long lo = 0, hi = 12345678912345;

    while(hi - lo > 2){
        long long ft = lo + (hi - lo) / 3;
        long long tt = hi - (hi - lo) / 3;

        int binaryLo = 0, binaryHi = a.size() - 1;
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] < ft) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size() - 1;
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] < ft) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = a.size() - 1;
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] < tt) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long AA = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size() - 1;
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] < tt) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long BB = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        if(AA - BB < A - B) lo = ft;
        else hi = tt;

    }

    int minn = lo - 4, maxx = lo + 4;
    for(lo = minn; lo <= maxx; lo++){

        int binaryLo = 0, binaryHi = a.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(a[mid] < lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long A = binaryLo * 2 + ((int)a.size() - binaryLo) * 3;

        binaryLo = 0, binaryHi = b.size();
        while(binaryLo < binaryHi){
            int mid = binaryLo + (binaryHi - binaryLo) / 2;
            if(b[mid] < lo) binaryLo = mid + 1;
            else binaryHi = mid;
        }
        long long B = binaryLo * 2 + ((int)b.size() - binaryLo) * 3;

        ans.push_back({A - B, {A, B}});

    }
    sort(all(ans), greater<pair<int, pair<int, int > > >());

    cout << ans[0].second.first << ":" << ans[0].second.second << endl;

    __();
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    sort(dist_a.begin(), dist_a.end());
    sort(dist_b.begin(), dist_b.end());

    set<int> ds;
    set_union(dist_a.begin(), dist_a.end(), dist_b.begin(), dist_b.end(), inserter(ds, ds.begin()));
    ds.insert(*ds.begin() - 1);

    int lower = min(dist_a.front(), dist_b.front());
    int upper = max(dist_a.back(), dist_b.back());

    int res_a = 0;
    int res_b = 0;
    int dif = INT_MIN;

    for (auto d : ds)
    {
        auto iter1 = upper_bound(dist_a.begin(), dist_a.end(), d);
        int j1 = iter1 - dist_a.begin();
        int first_points = 2 * j1 + 3 * (n - j1);

        auto iter2 = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j2 = iter2 - dist_b.begin();
        int second_points = 2 * j2 + 3 * (m - j2);

        if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
            dif = res_a - res_b;
        }
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    sort(dist_a.begin(), dist_a.end());
    sort(dist_b.begin(), dist_b.end());

    set<int> ds;
    set_union(dist_a.begin(), dist_a.end(), dist_b.begin(), dist_b.end(), inserter(ds, ds.begin()));
    ds.insert(*ds.begin() - 1);

    for (auto i : ds)
    {
        cout << i << ' ';
    }

    cout << '\n';

    int lower = min(dist_a.front(), dist_b.front());
    int upper = max(dist_a.back(), dist_b.back());

    int res_a = 0;
    int res_b = 0;
    int dif = INT_MIN;

    for (auto d : ds)
    {
        auto iter1 = upper_bound(dist_a.begin(), dist_a.end(), d);
        int j1 = iter1 - dist_a.begin();
        int first_points = 2 * j1 + 3 * (n - j1);

        auto iter2 = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j2 = iter2 - dist_b.begin();
        int second_points = 2 * j2 + 3 * (m - j2);

        if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
            dif = res_a - res_b;
        }
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    sort(dist_a.begin(), dist_a.end());
    sort(dist_b.begin(), dist_b.end());

    int res_a = 0;
    int res_b = 0;
    int dif = INT_MIN;

    for (int i = 0; i < n; ++i)
    {
        int d = dist_a[i] - 1;
        int first_points = 2 * i + 3 * (n - i);
        auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j = iter - dist_b.begin();
        int second_points = 2 * j + 3 * (m - j);
        if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
            dif = res_a - res_b;
        }
    }

    int d = dist_a[n - 1] + 1;
    int first_points = 2 * (n) + 3 * (0);
    auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
    int j = iter - dist_b.begin();
    int second_points = 2 * j + 3 * (m - j);
    if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
    {
        res_a = first_points;
        res_b = second_points;
        dif = res_a - res_b;
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    int res_a = INT_MIN;
    int res_b = INT_MIN;

    for (int i = 0; i < n; ++i)
    {
        int d = dist_a[i] - 1;
        int first_points = 2 * i + 3 * (n - i);
        auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j = iter - dist_b.begin();
        int second_points = 2 * j + 3 * (m - j);
        if (res_a - res_b < first_points - second_points || (res_a - res_b == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
        }
    }

    int d = dist_a[n - 1] + 1;
    int first_points = 2 * (n) + 3 * (0);
    auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
    int j = iter - dist_b.begin();
    int second_points = 2 * j + 3 * (m - j);
    if (res_a - res_b < first_points - second_points || (res_a - res_b == first_points - second_points && first_points > res_a))
    {
        res_a = first_points;
        res_b = second_points;
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    int res_a = 0;
    int res_b = 0;
    int dif = INT_MIN;

    for (int i = 0; i < n; ++i)
    {
        int d = dist_a[i] - 1;
        int first_points = 2 * i + 3 * (n - i);
        auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j = iter - dist_b.begin();
        int second_points = 2 * j + 3 * (m - j);
        if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
            dif = res_a - res_b;
        }
    }

    int d = dist_a[n - 1] + 1;
    int first_points = 2 * (n) + 3 * (0);
    auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
    int j = iter - dist_b.begin();
    int second_points = 2 * j + 3 * (m - j);
    if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
    {
        res_a = first_points;
        res_b = second_points;
        dif = res_a - res_b;
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    sort(dist_a.begin(), dist_a.end());
    sort(dist_b.begin(), dist_b.end());

    int lower = min(dist_a.front(), dist_b.front());
    int upper = max(dist_a.back(), dist_b.back());

    int res_a = 0;
    int res_b = 0;
    int dif = INT_MIN;

    for (int i = lower - 1; i <= upper; ++i)
    {
        auto iter1 = upper_bound(dist_a.begin(), dist_a.end(), i);
        int j1 = iter1 - dist_a.begin();
        int first_points = 2 * j1 + 3 * (n - j1);

        auto iter2 = upper_bound(dist_b.begin(), dist_b.end(), i);
        int j2 = iter2 - dist_b.begin();
        int second_points = 2 * j2 + 3 * (m - j2);

        if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
            dif = res_a - res_b;
        }
    }

    // int d = dist_a[n - 1] + 1;
    // int first_points = 2 * (n) + 3 * (0);
    // auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
    // int j = iter - dist_b.begin();
    // int second_points = 2 * j + 3 * (m - j);
    // if (dif < first_points - second_points || (dif == first_points - second_points && first_points > res_a))
    // {
    //     res_a = first_points;
    //     res_b = second_points;
    //     dif = res_a - res_b;
    // }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

inline void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    int n;
    cin >> n;

    vector<int> dist_a(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> dist_a[i];
    }

    int m;
    cin >> m;

    vector<int> dist_b(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> dist_b[i];
    }

    int res_a = 0;
    int res_b = 0;

    for (int i = 0; i < n; ++i)
    {
        int d = dist_a[i] - 1;
        int first_points = 2 * i + 3 * (n - i);
        auto iter = upper_bound(dist_b.begin(), dist_b.end(), d);
        int j = iter - dist_b.begin();
        int second_points = 2 * j + 3 * (m - j);
        if (res_a - res_b < first_points - second_points || (res_a - res_b == first_points - second_points && first_points > res_a))
        {
            res_a = first_points;
            res_b = second_points;
        }
    }

    cout << res_a << ':' << res_b << '\n';

    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
typedef long long ll;
#define clr(x,a) memset(x,a,sizeof(x))
#define sz(x) (int)x.size()
#define see(x) cerr<<#x<<" "<<x<<endl
#define se(x) cerr<<" "<<x
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for (long long i=l;i<=r;i++)
using namespace std;
bool cmp(int a,int b){
    return abs(a)<abs(b);
}
int a[1000000];
int main(){
    int n,m;cin>>n;
    rep(i,1,n){
        scanf("%d",&a[i]);
    }
    cin>>m;
    rep(i,1,m){
        scanf("%d",&a[n+i]);
        a[n+i]*=-1;
    }
    sort(a+1,a+1+n+m,cmp);
    int i=0,cnt1=0,cnt2=0,ans1=n*3,ans2=m*3;
    //an
    while (i<n){
        a[i]=a[i+1];
        while (i<n && abs(a[i])==abs(a[i+1])) {
            i++;
            if (a[i]>0) cnt1++;
            if (a[i]<0) cnt2++;
        }
        int tmp1=n*3-cnt1,tmp2=m*3-cnt2;
        if (tmp1-tmp2>ans1-ans2) {
            //cout<<i<<endl;
            ans1=tmp1;ans2=tmp2;
        }
    }
    cout<<ans1<<":"<<ans2<<endl;
    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
struct point{
    int a;
    int b;
};
point num[1000000];
bool cmp(point a,point b)
{
    if(a.a==b.a)
        return a.b>b.b;
    return a.a>b.a;
}
bool cmp1(point a,point b)
{
    if(a.a==b.a)
        return a.b<b.b;
    return a.a>b.a;
}
int main()
{
    int n1;
    cin>>n1;
    for(int i=0;i<n1;i++)
    {
        cin>>num[i].a;
        num[i].b=1;
    }
    int n2;
    cin>>n2;
    for(int i=0;i<n2;i++)
    {
        cin>>num[n1+i].a;
        num[n1+i].b=2;
    }
    sort(num,num+n1+n2,cmp);
    int ans=0;
    int kill=0;
    int flag=0;
    int flag2=0;
    for(int i=0;i<n1+n2;i++)
    {
        if(num[i].b==2)
            ans--;
        if(num[i].b==1)
            ans++;
        if(ans>0)
            ans=0;
        if(ans==0)
            flag=i;
    }
    int ans1=0;
    int ans2=0;
    for(int i=0;i<n1+n2;i++)
    {
        if(i<=flag)
        {
            if(num[i].b==1)
                ans1+=3;
            if(num[i].b==2)
                ans2+=3;
        }
        if(i>flag)
        {
            if(num[i].b==1)
                ans1+=2;
            if(num[i].b==2)
                ans2+=2;
        }
    }
    if(num[flag].b==2)
    {
        ans2-=1;
    }
    cout<<ans1<<":"<<ans2<<endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
typedef long long ll;
#define clr(x,a) memset(x,a,sizeof(x))
#define sz(x) (int)x.size()
#define see(x) cerr<<#x<<" "<<x<<endl
#define se(x) cerr<<" "<<x
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for (long long i=l;i<=r;i++)
using namespace std;
bool cmp(int a,int b){
    return abs(a)<abs(b);
}
int a[1000000];
int main(){
    int n,m;cin>>n;
    rep(i,1,n){
        scanf("%d",&a[i]);
    }
    cin>>m;
    rep(i,1,m){
        scanf("%d",&a[n+i]);
        a[n+i]*=-1;
    }
    sort(a+1,a+1+n+m,cmp);
    int i=0,cnt1=0,cnt2=0,ans1=n*3,ans2=m*3;
    //an
    while (i<m+n){
        a[i]=a[i+1];
        while (i<n+m && abs(a[i])==abs(a[i+1])) {
            i++;
            if (a[i]>0) cnt1++;
            if (a[i]<0) cnt2++;
        }
        cout<<i<<endl;
        int tmp1=n*3-cnt1,tmp2=m*3-cnt2;
        if (tmp1-tmp2>ans1-ans2) {
            //cout<<i<<endl;
            ans1=tmp1;ans2=tmp2;
        }
    }
    cout<<ans1<<":"<<ans2<<endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
typedef long long ll;
#define clr(x,a) memset(x,a,sizeof(x))
#define sz(x) (int)x.size()
#define see(x) cerr<<#x<<" "<<x<<endl
#define se(x) cerr<<" "<<x
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for (long long i=l;i<=r;i++)
using namespace std;
bool cmp(int a,int b){
    return abs(a)<abs(b);
}
int a[1000000];
int main(){
    int n,m;cin>>n;
    rep(i,1,n){
        scanf("%d",&a[i]);
    }
    cin>>m;
    rep(i,1,m){
        scanf("%d",&a[n+i]);
        a[n+i]*=-1;
    }
    sort(a+1,a+1+n+m,cmp);
    int i=0,cnt1=0,cnt2=0,ans1=n*3,ans2=m*3;
    //an
    while (i<m+n){
        a[i]=a[i+1];
        while (i<n+m && abs(a[i])==abs(a[i+1])) {
            i++;
            if (a[i]>0) cnt1++;
            if (a[i]<0) cnt2++;
        }
        //cout<<i<<endl;
        int tmp1=n*3-cnt1,tmp2=m*3-cnt2;
        if (tmp1-tmp2>ans1-ans2) {
            //cout<<i<<endl;
            ans1=tmp1;ans2=tmp2;
        }
    }
    cout<<ans1<<":"<<ans2<<endl;
    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
struct point{
    int a;
    int b;
};
point num[1000000];
bool cmp(point a,point b)
{
    if(a.a==b.a)
        return a.b>b.b;
    return a.a>b.a;
}
int main()
{
    int n1;
    cin>>n1;
    for(int i=0;i<n1;i++)
    {
        cin>>num[i].a;
        num[i].b=1;
    }
    int n2;
    cin>>n2;
    for(int i=0;i<n2;i++)
    {
        cin>>num[n1+i].a;
        num[n1+i].b=2;
    }
    sort(num,num+n1+n2,cmp);
    int ans=0;
    int kill=0;
    int flag=0;
    int flag2=0;
    for(int i=0;i<n1+n2;i++)
    {
        if(num[i].b==2)
            ans--;
        if(num[i].b==1)
            ans++;
        if(ans>0)
            ans=0;
        if(ans==0)
            flag=i;
    }
    int ans1=0;
    int ans2=0;
    for(int i=0;i<n1+n2;i++)
    {
        if(i<=flag)
        {
            if(num[i].b==1)
                ans1+=3;
            if(num[i].b==2)
                ans2+=3;
        }
        if(i>flag)
        {
            if(num[i].b==1)
                ans1+=2;
            if(num[i].b==2)
                ans2+=2;
        }
    }
    cout<<ans1<<":"<<ans2<<endl;
    return 0;
}


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

public class A {

	static long solve(long x, long y, long q){
		long p = 1;
		long l = 1;
		long h = (long) 1e8;
		long ans = -1;
		while(l <= h) {
			long mid = (l + h) / 2;
			if(1l * p * mid - x <= 1l * q * mid - y && 1l * p * mid >= x) {
				ans = mid;
				h = mid - 1;
			}else
				l = mid + 1;
		}
		return(ans == -1 ? ans : ans * q - y);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int[] occ = new int[50];
		ArrayList<Long> barra = new ArrayList<>();
		int total = 0;
		for (int i = 0; i < n; i++) {
			long x = sc.nextLong();

			int a = 0;

			while(1l << a <= x) {
				if(1l << a == x) {
					occ[a]++;
					total++;
					break;
				} else
					a++;
			}

			if(1l << a > x)
				barra.add(x);
		}
		if(occ[0] == 0 || n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}

		int[] arr = new int[occ[0]];
		Arrays.fill(arr, 1);

		int end = occ[0];
		for (int i = 1; i < occ.length; i++) {
			for (int j = end; j < occ[i]; j++)
				barra.add((1l << i));
			end = Math.min(occ[i], end);
			for (int j = 0; j < end; j++) {
				arr[j]++;
			}

		}
		if(barra.size() > occ[0])
		{
			System.out.println(-1);
			return;
		}
		Collections.sort(barra);
		for (int i = barra.size() - 1, j = 0; i >= 0; i--, j++) {
			if(barra.get(i) >= (1l << arr[j])) {
				System.out.println(-1);
				return;
			}
		}
		int l = arr.length;
		int r = l;
		int start = barra.size();
		for (int i = arr.length - 1; i >= 0; i--) {
			if(start + arr[i] > i)
				break;

			start += arr[i];
			l = i;
		}

		for (int i = l; i <= r; i++)
			out.print(i + " ");
		out.println();
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


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

public class A {

	static long solve(long x, long y, long q){
		long p = 1;
		long l = 1;
		long h = (long) 1e8;
		long ans = -1;
		while(l <= h) {
			long mid = (l + h) / 2;
			if(1l * p * mid - x <= 1l * q * mid - y && 1l * p * mid >= x) {
				ans = mid;
				h = mid - 1;
			}else
				l = mid + 1;
		}
		return(ans == -1 ? ans : ans * q - y);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int[] occ = new int[50];
		int total = 0;
		for (int i = 0; i < n; i++) {
			long x = sc.nextLong();

			int a = 0;

			while(1l << a <= x) {
				if(1l << a == x) {
					occ[a]++;
					total++;
				}
				a++;
			}
		}
		if(occ[0] == 0 || n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}
		int[] arr = new int[occ[0]];

		int start = n - total;
		int end = occ[0];
		for (int i = 1; i < occ.length; i++) {
			if(occ[i] == 0)
				continue;
			if(occ[i] > end) {
				System.out.println(-1);
				return;
			}
			for (int j = 0; j < occ[i]; j++) {
				arr[j]++;
			}

			end = occ[i];
		}

		int l = arr.length;
		int r = l;
		for (int i = arr.length - 1; i >= 0; i--) {
			if(start + arr[i] >= i)
				break;

			start += arr[i];
			l = i;
		}

		for (int i = l; i <= r; i++)
			out.print(i + " ");
		out.println();
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


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

public class A {

	static long solve(long x, long y, long q){
		long p = 1;
		long l = 1;
		long h = (long) 1e8;
		long ans = -1;
		while(l <= h) {
			long mid = (l + h) / 2;
			if(1l * p * mid - x <= 1l * q * mid - y && 1l * p * mid >= x) {
				ans = mid;
				h = mid - 1;
			}else
				l = mid + 1;
		}
		return(ans == -1 ? ans : ans * q - y);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int[] occ = new int[50];
		ArrayList<Long> barra = new ArrayList<>();
		int total = 0;
		for (int i = 0; i < n; i++) {
			long x = sc.nextLong();

			int a = 0;

			while(1l << a <= x) {
				if(1l << a == x) {
					occ[a]++;
					total++;
					break;
				} else
					a++;
			}

			if(1l << a > x)
				barra.add(x);
		}
		if(occ[0] == 0 || n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}

		int[] arr = new int[occ[0]];
		Arrays.fill(arr, 1);
		int start = barra.size();
		int end = occ[0];
		for (int i = 1; i < occ.length; i++) {
			for (int j = end; j < occ[i]; j++)
				barra.add((1l << i));
			end = Math.min(occ[i], end);
			for (int j = 0; j < end; j++) {
				arr[j]++;
			}

		}
		if(barra.size() > occ[0])
		{
			System.out.println(-1);
			return;
		}
		Collections.sort(barra);
		for (int i = barra.size() - 1, j = 0; i >= 0; i--, j++) {
			if(barra.get(i) >= (1l << arr[j])) {
				System.out.println(-1);
				return;
			}
		}
		int l = arr.length;
		int r = l;
		for (int i = arr.length - 1; i >= 0; i--) {
			if(start + arr[i] > i)
				break;

			start += arr[i];
			l = i;
		}

		for (int i = l; i <= r; i++)
			out.print(i + " ");
		out.println();
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


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

public class A {

	static long solve(long x, long y, long q){
		long p = 1;
		long l = 1;
		long h = (long) 1e8;
		long ans = -1;
		while(l <= h) {
			long mid = (l + h) / 2;
			if(1l * p * mid - x <= 1l * q * mid - y && 1l * p * mid >= x) {
				ans = mid;
				h = mid - 1;
			}else
				l = mid + 1;
		}
		return(ans == -1 ? ans : ans * q - y);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int[] occ = new int[50];
		ArrayList<Long> barra = new ArrayList<>();
		int total = 0;
		for (int i = 0; i < n; i++) {
			long x = sc.nextLong();

			int a = 0;

			while(1l << a <= x) {
				if(1l << a == x) {
					occ[a]++;
					total++;
					break;
				} else
					a++;
			}

			if(1l << a > x)
				barra.add(x);
		}
		if(occ[0] == 0 || n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}

		int[] arr = new int[occ[0]];
		Arrays.fill(arr, 1);
		int start = barra.size();
		int end = occ[0];
		for (int i = 1; i < occ.length; i++) {
			for (int j = end; j < occ[i]; j++)
				barra.add((1l << i));
			end = Math.min(occ[i], end);
			for (int j = 0; j < end; j++) {
				arr[j]++;
			}

		}
		if(n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}
		Collections.sort(barra);
		for (int i = barra.size() - 1, j = 0; i >= 0; i--, j++) {
			if(barra.get(i) >= (1l << arr[j])) {
				System.out.println(-1);
				return;
			}
		}
		int l = arr.length;
		int r = l;
		for (int i = arr.length - 1; i >= 0; i--) {
			if(start + arr[i] > i)
				break;

			start += arr[i];
			l = i;
		}

		for (int i = l; i <= r; i++)
			out.print(i + " ");
		out.println();
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


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

public class A {

	static long solve(long x, long y, long q){
		long p = 1;
		long l = 1;
		long h = (long) 1e8;
		long ans = -1;
		while(l <= h) {
			long mid = (l + h) / 2;
			if(1l * p * mid - x <= 1l * q * mid - y && 1l * p * mid >= x) {
				ans = mid;
				h = mid - 1;
			}else
				l = mid + 1;
		}
		return(ans == -1 ? ans : ans * q - y);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		int[] occ = new int[50];
		ArrayList<Long> barra = new ArrayList<>();
		int total = 0;
		for (int i = 0; i < n; i++) {
			long x = sc.nextLong();

			int a = 0;

			while(1l << a <= x) {
				if(1l << a == x) {
					occ[a]++;
					total++;
					break;
				} else
					a++;
			}

			if(1l << a > x)
				barra.add(x);
		}
		if(occ[0] == 0 || n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}

		int[] arr = new int[occ[0]];
		Arrays.fill(arr, 1);
		int start = barra.size();
		int end = occ[0];
		for (int i = 1; i < occ.length; i++) {
			for (int j = end; j < occ[i]; j++)
				barra.add((1l >> i));
			end = Math.min(occ[i], end);
			for (int j = 0; j < end; j++) {
				arr[j]++;
			}

		}
		if(n - total > occ[0])
		{
			System.out.println(-1);
			return;
		}
		Collections.sort(barra);
		for (int i = barra.size() - 1, j = 0; i >= 0; i--, j++) {
			if(barra.get(i) >= (1l << arr[j])) {
				System.out.println(-1);
				return;
			}
		}
		int l = arr.length;
		int r = l;
		for (int i = arr.length - 1; i >= 0; i--) {
			if(start + arr[i] > i)
				break;

			start += arr[i];
			l = i;
		}

		for (int i = l; i <= r; i++)
			out.print(i + " ");
		out.println();
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class C {

    public static final int N = 50;

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        int[] p = new int[N];
        int[] e = new int[N];
        int j = 0;
        for (int i = 0; i < N; i++) {
            while (j < n && a[j] < (1L << i)) {
                e[i]++;
                j++;
            }
            while (j < n && a[j] == (1L << i)) {
                p[i]++;
                j++;
            }
            if (i > 0 && p[i] > p[i - 1]) {
                e[i + 1] += (p[i] - p[i - 1]);
                p[i] = p[i - 1];
            }
        }

        int l = 0;
        int r = p[0] + 1;
        int[] pp = p.clone();
        int[] ee = e.clone();
        while (r > l + 1) {
            int k = (l + r) / 2;
            System.arraycopy(p, 0, pp, 0, p.length);
            System.arraycopy(e, 0, ee, 0, e.length);
            ee[1] += pp[0] - k;
            pp[0] = k;
            for (int i = 0; i < N; i++) {
                if (i > 0 && pp[i] > pp[i - 1]) {
                    ee[i + 1] += (pp[i] - pp[i - 1]);
                    pp[i] = pp[i - 1];
                }
            }
            if (can(pp, ee)) {
                r = k;
            } else {
                l = k;
            }
        }
        if (r == p[0] + 1) {
            out.println(-1);
        } else {
            for (int i = r; i <= p[0]; i++) {
                out.println(i);
            }
        }
    }

    private boolean can(int[] p, int[] e) {
//        System.out.println(Arrays.toString(p) + " " + Arrays.toString(e));
        int s = 0;
        for (int i = N - 2; i >= 0; i--) {
            s += (p[i] - p[i + 1]);
            if (s < e[i + 1]) {
                return false;
            }
            s -= e[i + 1];
        }
        return true;
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class C {

    public static final int N = 50;

    private void solve() throws IOException {
        int n = nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        int[] p = new int[N];
        int[] e = new int[N];
        int j = 0;
        for (int i = 0; i < N; i++) {
            while (j < n && a[j] < (1L << i)) {
                e[i]++;
                j++;
            }
            while (j < n && a[j] == (1L << i)) {
                p[i]++;
                j++;
            }
            if (i > 0 && p[i] > p[i - 1]) {
                e[i + 1] += (p[i] - p[i - 1]);
                p[i] = p[i - 1];
            }
        }

        int l = 0;
        int r = p[0] + 1;
        int[] pp = p.clone();
        int[] ee = e.clone();
        while (r > l + 1) {
            int k = (l + r) / 2;
            System.arraycopy(p, 0, pp, 0, p.length);
            System.arraycopy(e, 0, ee, 0, e.length);
            ee[1] += pp[0] - k;
            pp[0] = k;
            for (int i = 0; i < N; i++) {
                if (i > 0 && pp[i] > pp[i - 1]) {
                    ee[i + 1] += (pp[i] - pp[i - 1]);
                    pp[i] = pp[i - 1];
                }
            }
            if (can(pp, ee)) {
                r = k;
            } else {
                l = k;
            }
        }
        if (r == p[0] + 1) {
            out.println(-1);
        } else {
            for (int i = r; i <= p[0]; i++) {
                out.println(i);
            }
        }
    }

    private boolean can(int[] p, int[] e) {
//        System.out.println(Arrays.toString(p) + " " + Arrays.toString(e));
        int s = 0;
        for (int i = N - 2; i >= 0; i--) {
            s += (p[i] - p[i + 1]);
            if (s < e[i + 1]) {
                return false;
            }
            s -= e[i + 1];
        }
        return true;
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class C {

    public static final int N = 50;

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        int[] p = new int[N];
        int[] e = new int[N];
        int j = 0;
        for (int i = 0; i < N; i++) {
            while (j < n && a[j] < (1L << i)) {
                e[i]++;
                j++;
            }
            while (j < n && a[j] == (1L << i)) {
                p[i]++;
                j++;
            }
            if (i > 0 && p[i] > p[i - 1]) {
                e[i] += (p[i] - p[i - 1]);
                p[i] = p[i - 1];
            }
        }

        int l = 0;
        int r = p[0] + 1;
        int[] pp = p.clone();
        int[] ee = e.clone();
        while (r > l + 1) {
            int k = (l + r) / 2;
            System.arraycopy(p, 0, pp, 0, p.length);
            System.arraycopy(e, 0, ee, 0, e.length);
            ee[0] += pp[0] - k;
            pp[0] = k;
            for (int i = 0; i < N; i++) {
                if (i > 0 && pp[i] > pp[i - 1]) {
                    ee[i] += (pp[i] - pp[i - 1]);
                    pp[i] = pp[i - 1];
                }
            }
            if (can(pp, ee)) {
                r = k;
            } else {
                l = k;
            }
        }
        if (r == p[0] + 1) {
            out.println(-1);
        } else {
            for (int i = r; i <= p[0]; i++) {
                out.println(i);
            }
        }
    }

    private boolean can(int[] p, int[] e) {
//        System.out.println(Arrays.toString(p) + " " + Arrays.toString(e));
        int s = 0;
        for (int i = N - 2; i >= 0; i--) {
            s += (p[i] - p[i + 1]);
            if (s < e[i + 1]) {
                return false;
            }
            s -= e[i + 1];
        }
        return true;
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


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

public class CopyOfSnippet {

	public static void main(String[] args) {
		FastScanner input = new FastScanner();
		int n = input.nextInt();
		long[] arr = input.readLongArray(n);
		shuffle(arr);
		Arrays.sort(arr);
		int[] pow2FreqDist = new int[60];
		ArrayList<Long> notPow2 = new ArrayList<Long>();
		for (int a = 0; a < n; a++) {
			int cache = isPow2(arr[a]);
			if (cache >= 0) {
				pow2FreqDist[cache]++;
			} else {
				notPow2.add(arr[a]);
			}
		}
		// clean data. If we have extra pow, add it to notPow2 list.
		for (int a = 1; a < 60; a++) {
			while (pow2FreqDist[a] > pow2FreqDist[a - 1]) {
				pow2FreqDist[a]--;
				notPow2.add(1l << a);
			}
		}
		Collections.sort(notPow2);
		int[] notPow2Magnitude = new int[60];
		for(long i:notPow2){
			notPow2Magnitude[largestPow2(i)]++;
		}
		int maxOne = pow2FreqDist[0];
		int pointer1 = 59;
		int pointer2 = 59;
		while(pointer1 != -1 && pointer2 != -1){
			if(notPow2Magnitude[pointer2] == 0){
				pointer2--;
				continue;
			}
			if(pow2FreqDist[pointer1] == 0){
				pointer1--;
				continue;
			}
			if(pointer2 > pointer1){
				pointer1--;
			}
			else{
				notPow2Magnitude[pointer2]--;
				for(int x = pointer1; x >= 0; x--){
					pow2FreqDist[x]--;
				}
			}
		}
		if(pointer1 == -1){
			System.out.println(-1);
			System.exit(0);
		}
		//time to find the minimum
		int[] freqDistDist = new int[60];
		for(int a = 0; a < 59; a++){
			freqDistDist[a] = pow2FreqDist[a]-pow2FreqDist[a+1];
		}
		int sum = 0;
		for(int a = 0; a < 60; a++){
			sum += freqDistDist[a];
		}
		int removeCount = 0;
		int remove = 0;
		lbl:
		for(int a = 0; a < 60; a++){
			for(int x = 0; x < freqDistDist[a]; x++){
				//try to remove
				int seqToRem = (a+1)+1;
				remove += seqToRem;
				if(remove <= sum){
					removeCount++;
				}
				else{
					break lbl;
				}
			}
		}
		StringBuilder output = new StringBuilder();
		for(int a = maxOne-removeCount; a <= maxOne; a++){
			output.append(a + " ");
		}
		System.out.println(output);

		//time to find the maximum. Place every '1' on it's own line. Can't ever beat that. Nor, will removing a 1 ever help.

//		System.err.println(Arrays.toString(pow2FreqDist));
//		System.err.println(Arrays.toString(notPow2Magnitude));
	}
	static int largestPow2(long in){
		int count = 0;
		while (in != 1) {
			in = in / 2;
			count++;
		}
		return count;
	}
	static int isPow2(long in) {
		int count = 0;
		while (in != 1) {
			if (in % 2 == 1) {
				return -1;
			}
			in = in / 2;
			count++;
		}
		return count;
	}

	static void shuffle(long[] arr) {
		Random rng = new Random();
		int length = arr.length;
		for (int idx = 0; idx < arr.length; idx++) {
			int toSwap = idx + rng.nextInt(length - idx);
			long tmp = arr[idx];
			arr[idx] = arr[toSwap];
			arr[toSwap] = tmp;
		}
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(Reader in) {
			br = new BufferedReader(in);
		}

		public FastScanner() {
			this(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String readNextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readIntArray(int n) {
			int[] a = new int[n];
			for (int idx = 0; idx < n; idx++) {
				a[idx] = nextInt();
			}
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int idx = 0; idx < n; idx++) {
				a[idx] = nextLong();
			}
			return a;
		}
	}
}


import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static void solve() throws Exception {
		int n = nextInt();
		int pows[] = new int[45];
		int powsT[] = new int[45];
		for (int i = 0; i < n; i++) {
			long x = nextLong();
			if ((x & -x) == x) {
				++pows[Long.numberOfTrailingZeros(x)];
			} else {
				++powsT[Long.numberOfTrailingZeros(x & -x) + 1];
			}
		}
		boolean can = false;
		for (int res = 1; res <= pows[0]; res++) {
			int terms = 0;
			for (int i = 0; i < 45; i++) {
				terms += powsT[i] + max(pows[i] - res, 0);
			}
			if (terms > res) {
				continue;
			}
			int have = res, haveTerms = max(pows[0] - res, 0);
			for (int i = 0; i < 44; i++) {
				have = min(have, pows[i]);
				haveTerms += powsT[i + 1] + max(pows[i + 1] - have, 0);
				haveTerms = max(haveTerms - have, 0);
			}
			if (haveTerms == 0) {
				if (can) {
					out.print(' ');
				} else {
					can = true;
				}
				out.print(res);
			}
		}
		if (!can) {
			out.print(-1);
		}
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static void solve() throws Exception {
		int n = nextInt();
		int pows[] = new int[45];
		int powsT[] = new int[45];
		for (int i = 0; i < n; i++) {
			long x = nextLong();
			if ((x & -x) == x) {
				++pows[Long.numberOfTrailingZeros(x)];
			} else {
				++powsT[Long.numberOfTrailingZeros(Long.highestOneBit(x)) + 1];
			}
		}
		boolean can = false;
		for (int res = 1; res <= pows[0]; res++) {
			int terms = 0;
			for (int i = 0; i < 45; i++) {
				terms += powsT[i] + max(pows[i] - res, 0);
			}
			if (terms > res) {
				continue;
			}
			int have = res, haveTerms = max(pows[0] - res, 0);
			for (int i = 0; i < 44; i++) {
				have = min(have, pows[i]);
				haveTerms += powsT[i + 1] + max(pows[i + 1] - have, 0);
				haveTerms = max(haveTerms - have, 0);
			}
			if (haveTerms == 0) {
				if (can) {
					out.print(' ');
				} else {
					can = true;
				}
				out.print(res);
			}
		}
		if (!can) {
			out.print(-1);
		}
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static void solve() throws Exception {
		int n = nextInt();
		int pows[] = new int[45];
		int powsT[] = new int[45];
		for (int i = 0; i < n; i++) {
			long x = nextLong();
			if ((x & -x) == x) {
				++pows[Long.numberOfTrailingZeros(x)];
			} else {
				++powsT[Long.numberOfTrailingZeros(Long.highestOneBit(x)) + 1];
			}
		}
		boolean can = false;
		for (int res = 1; res <= pows[0]; res++) {
			int terms = 0;
			for (int i = 0; i < 45; i++) {
				terms += powsT[i] + max(pows[i] - res, 0);
			}
			if (terms > res) {
				continue;
			}
			int have = res, haveTerms = max(pows[0] - res, 0);
			for (int i = 0; i < 44; i++) {
//				have = min(have, pows[i]);
//				haveTerms += powsT[i + 1] + max(pows[i + 1] - have, 0);
//				haveTerms = max(haveTerms - have, 0);
				haveTerms = max(haveTerms - max(have - pows[i], 0), 0);
				have = min(have, pows[i]);
				haveTerms += powsT[i + 1] + max(pows[i + 1] - have, 0);
			}
			if (haveTerms == 0) {
				if (can) {
					out.print(' ');
				} else {
					can = true;
				}
				out.print(res);
			}
		}
		if (!can) {
			out.print(-1);
		}
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    class GraphBuilder {
        int n, m;
        int[] x, y;
        int index;
        int[] size;

        GraphBuilder(int n, int m) {
            this.n = n;
            this.m = m;
            x = new int[m];
            y = new int[m];
            size = new int[n];
        }

        void add(int u, int v) {
            x[index] = u;
            y[index] = v;
            size[u]++;
            size[v]++;
            index++;
        }

        int[][] build() {
            int[][] graph = new int[n][];
            for (int i = 0; i < n; i++) {
                graph[i] = new int[size[i]];
            }
            for (int i = index - 1; i >= 0; i--) {
                int u = x[i];
                int v = y[i];
                graph[u][--size[u]] = v;
                graph[v][--size[v]] = u;
            }
            return graph;
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = readLong();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int BITS = 45;

    void solve() throws IOException {
        int n = readInt();
        long[] a = readLongArray(n);
        int[] powerCount = new int[BITS];
        int[] lowerThan = new int[BITS];
        long curPower = 1;
        int powerIndex = 0;
        for (long x : a) {
            while (curPower < x) {
                curPower *= 2;
                powerIndex++;
            }
            if (curPower == x) {
                powerCount[powerIndex]++;
            } else {
                lowerThan[powerIndex]++;
            }
        }

        ArrayList<Integer> avails = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            if (powerCount[0] >= i) {
                if (ok(powerCount, lowerThan, i)) {
                    avails.add(i);
                }
            }
        }
        if (avails.size() == 0) {
            out.println(-1);
        } else {
            for (int x : avails) {
                out.print(x + " ");
            }
        }
    }

    boolean ok(int[] powerCount,int[] lowerThan, int target) {
        int lower = 0;
        for (int i = 0; i < powerCount.length; i++) {
            lower += lowerThan[i];
            if (powerCount[i] < target) {
                int diff = target - powerCount[i];
                target = powerCount[i];
                lower = Math.max(0, lower - diff);
            } else if (powerCount[i] > target) {
                lower += powerCount[i] - target;
            }
        }
        if (lower > target) return false;
        return true;
    }

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    class GraphBuilder {
        int n, m;
        int[] x, y;
        int index;
        int[] size;

        GraphBuilder(int n, int m) {
            this.n = n;
            this.m = m;
            x = new int[m];
            y = new int[m];
            size = new int[n];
        }

        void add(int u, int v) {
            x[index] = u;
            y[index] = v;
            size[u]++;
            size[v]++;
            index++;
        }

        int[][] build() {
            int[][] graph = new int[n][];
            for (int i = 0; i < n; i++) {
                graph[i] = new int[size[i]];
            }
            for (int i = index - 1; i >= 0; i--) {
                int u = x[i];
                int v = y[i];
                graph[u][--size[u]] = v;
                graph[v][--size[v]] = u;
            }
            return graph;
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = readLong();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int BITS = 45;

    void solve() throws IOException {
        int n = readInt();
        long[] a = readLongArray(n);
        int[] powerCount = new int[BITS];
        int[] lowerThan = new int[BITS];
        long curPower = 1;
        int powerIndex = 0;
        for (long x : a) {
            while (curPower < x) {
                curPower *= 2;
                powerIndex++;
            }
            if (curPower == x) {
                powerCount[powerIndex]++;
            } else {
                lowerThan[powerIndex]++;
            }
        }

        ArrayList<Integer> avails = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            if (powerCount[0] >= i) {
                if (ok(powerCount, i)) {
                    avails.add(i);
                }
            }
        }
        if (avails.size() == 0) {
            out.println(-1);
        } else {
            for (int x : avails) {
                out.print(x + " ");
            }
        }
    }

    boolean ok(int[] powerCount, int target) {
        int lower = 0;
        for (int i = 0; i < powerCount.length; i++) {
            if (powerCount[i] < target) {
                int diff = target - powerCount[i];
                target = powerCount[i];
                lower = Math.max(0, lower - diff);
            } else if (powerCount[i] > target) {
                lower += powerCount[i] - target;
            }
        }
        if (lower > target) return false;
        return true;
    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HR20C {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    static class Sort implements Comparable<Sort> {
        int ind, a;

        @Override
        public int compareTo(Sort o) {
            return a - o.a;
        }
        public Sort(int i, int an) {
            ind = i;
            a = an;
        }
    }

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        solve();
        pw.close();
    }

    static int[] kol = new int [60];
    static int[] p2 = new int [60];
    static HashMap<Long, Integer> hm = new HashMap<>();

    private static void solve() throws IOException {
    	for (int i = 0; i < 60; ++i) {
    		hm.put(1L << i, i);
    	}
    	int n = nextInt();
    	ArrayList<Long> al = new ArrayList<>();
    	long cur;
    	for (int i = 0; i < n; ++i) {
    		cur = nextLong();
    		if (Long.bitCount(cur) == 1) {
    			kol[hm.get(cur)]++;
    		} else {
    			al.add(cur);
    		}
    	}
    	//for (int i = 0; i < 59; ++i)
    	//	System.out.print(kol[i] + " ");
    	int sp = 0;
    	for (int i = 59; i >= 0; --i) {
    		while (kol[i] > 0) {
    			if (have(i)) {
    				for (int j = i; j >= 0; --j)
    					--kol[j];
    				p2[i]++;
    				++sp;
    			} else {
    				al.add(1l << i);
    				--kol[i];
    			}
    		}
    	}
    	if (al.size() > sp) {
    		pw.println(-1);
    		return;
    	}
    	Collections.sort(al);
    	TreeSet<Integer> ans = new TreeSet<Integer>();
    	for (int i = al.size() - 1; i >= 0; --i) {
    		if (can(al.get(i))) {
    		} else {
    			pw.println(-1);
    			return;
    		}
    	}
    	ans.add(sp);
    	boolean br;
    	while (true) {
    		al.clear();
    		for (int i = 0; i < 60; ++i) {
    			if (p2[i] > 0) {
    				--p2[i];
    				for (int j = 0; j <= i; ++j)
    					al.add(1l << j);
    				break;
    			}
    		}
    		if (al.size() == 0)
    			break;
    		br = false;
        	for (int i = al.size() - 1; i >= 0; --i) {
        		if (can(al.get(i))) {
        		} else {
        			br= true;
        			break;
        		}
        	}
    		if (!br) {
    			--sp;
    			ans.add(sp);
    		} else {
    			break;
    		}

    	}
    	for (int w : ans) {
    		pw.print(w + " ");
    	}
    }

	private static boolean can(Long a) {
		for (int i = 59; i >= 0; --i) {
			if (p2[i] > 0) {
				if (1l << (i + 1) > a) {
					--p2[i];
					return true;
				} else {
					return false;
				}
			}
		}
		return false;
	}

	private static boolean have(int i) {
		for (int j = i; j >= 0; --j)
			if (kol[j] == 0)
				return false;
		return true;
	}

	private static int sumf(int[] fen, int id) {
        int summ = 0;
        for (; id >= 0; id = (id & (id + 1)) - 1)
            summ += fen[id];
        return summ;
    }

    private static void addf(int[] fen, int id) {
        for (; id < fen.length; id |= id + 1)
            fen[id]++;
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


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

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));
        //String test = "sample";
        //ConsoleIO io = new ConsoleIO(new FileReader("D:\\Dropbox\\code\\practice\\jb\\src\\" + test + ".in"), new PrintWriter(new File("D:\\Dropbox\\code\\practice\\jb\\src\\" + test + "-out.txt")));

        new Main(io).solve();
        io.close();
    }

    ConsoleIO io;
    Main(ConsoleIO io) {
        this.io = io;
    }

    long MOD = 1_000_000_007;

    public void solve() {
        int n = io.ri();
        int pow = 45;
        int[] count = new int[pow];
        List<Long> other = new ArrayList<>();
        for(int i = 0;i<n;i++) {
            long v = io.readLong();
            boolean ooo = true;
            for (int j = 0; j < pow; j++) {
                if (v == 1L << j) {
                    count[j]++;
                    ooo = false;
                    break;
                }
            }
            if (ooo)
                other.add(v);
        }

        for(int i = 1;i<pow;i++) {
            if (count[i] > count[i - 1]) {
                int t = count[i] - count[i - 1];
                count[i] = count[i - 1];
                for (int j = 0; j < t; j++)
                    other.add(1L << i);
            }
        }

        if(other.size()>count[0]){
            io.writeLine("-1");
            return;
        }

        other.sort(Comparator.naturalOrder());
        int k = other.size()-1;

        int max = count[0];
        int min = 0;
        for(int i = pow-1;i>=0;i--) {
            while (count[i] > 0) {
                if (k >= 0) {
                    long v = other.get(k);
                    if (v > 1L << (i + 1)) {
                        io.writeLine("-1");
                        return;
                    }
                    k--;
                    for (int j = i; j >= 0; j--)
                        count[j]--;
                } else {
                    for (int j = i; j >= 0; j--)
                        count[j]--;
                    for (int j = 0; j <= i; j++)
                        if (count[j] > count[j + 1]) {
                            count[j]--;
                            break;
                        }
                }
                min++;
            }
        }

        StringBuilder sb = new StringBuilder();
        for(int i = min;i<=max;i++){
            if(i>min)sb.append(' ');
            sb.append(i);
        }
        io.writeLine(sb.toString());
    }
}

class ConsoleIO {
    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(Reader reader, PrintWriter writer){br = new BufferedReader(reader);out = writer;}
    public void flush(){this.out.flush();}
    public void close(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public void writeIntArray(int[] a, int k, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < k; i++) {
            if (i > 0) sb.append(separator);
            sb.append(a[i]);
        }
        this.writeLine(sb.toString());
    }
    public int read(char[] buf, int len){try {return br.read(buf,0,len);}catch (Exception ex){ return -1; }}
    public String readLine() {try {return br.readLine();}catch (Exception ex){ return "";}}
    public long[] readLongArray() {
        String[]n=this.readLine().trim().split("\\s+");long[]r=new long[n.length];
        for(int i=0;i<n.length;i++)r[i]=Long.parseLong(n[i]);
        return r;
    }
    public int[] readIntArray() {
        String[]n=this.readLine().trim().split("\\s+");int[]r=new int[n.length];
        for(int i=0;i<n.length;i++)r[i]=Integer.parseInt(n[i]);
        return r;
    }
    public int[] readIntArray(int n) {
        int[] res = new int[n];
        char[] all = this.readLine().toCharArray();
        int cur = 0;boolean have = false;
        int k = 0;
        boolean neg = false;
        for(int i = 0;i<all.length;i++){
            if(all[i]>='0' && all[i]<='9'){
                cur = cur*10+all[i]-'0';
                have = true;
            }else if(all[i]=='-') {
                neg = true;
            }
            else if(have){
                res[k++] = neg?-cur:cur;
                cur = 0;
                have = false;
                neg = false;
            }
        }
        if(have)res[k++] = neg?-cur:cur;
        return res;
    }
    public int ri() {
        try {
            int r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public long readLong() {
        try {
            long r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public String readWord() {
        try {
            boolean start = false;
            StringBuilder sb = new StringBuilder();
            while (true) {
                int c = br.read();
                if (c!= ' ' && c!= '\r' && c!='\n' && c!='\t') {
                    sb.append((char)c);
                    start = true;
                } else if (start || c == -1) return sb.toString();
            }
        } catch (Exception ex) {
            return "";
        }
    }
    public char readSymbol() {
        try {
            while (true) {
                int c = br.read();
                if (c != ' ' && c != '\r' && c != '\n' && c != '\t') {
                    return (char) c;
                }
            }
        } catch (Exception ex) {
            return 0;
        }
    }
    //public char readChar(){try {return (char)br.read();}catch (Exception ex){ return 0; }}
}