n = int(input())
a = list(map(int, input().split()))
a.sort()
s = set(a)
if len(s) == (n + 1) >> 1:
    i = 0
    index = 0
    while i < n:
        count = 0
        number = a[i]
        while i < n and a[i] == number:
            count+=1
            i+=1
        zeros = 32
        mod = 0xffffffff
        while index & mod:
            zeros-=1
            mod>>=1
        if index:
            if count != zeros + 1:
                print('-1')
                break
        else:
            number = len(s) >> 1
            zeros = 0
            while number:
                zeros+=1
                number>>=1
            if count != zeros + 1:
                print('-1')
                break
        index+=1
    else:
        print(' '.join([str(i) for i in sorted(list(s))]))
else:
    print('-1')