import sys
from math import gcd,sqrt,ceil,log2
from collections import defaultdict,Counter,deque
from bisect import bisect_left,bisect_right
import math

sys.setrecursionlimit(2*10**5+10)
import heapq
from itertools import permutations

# input=sys.stdin.readline
# def print(x):
#     sys.stdout.write(str(x)+"\n")

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

aa='abcdefghijklmnopqrstuvwxyz'
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# import sys
# import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def get_sum(bit,i):
    s = 0

    i+=1
    while i>0:
        s+=bit[i]
        i-=i&(-i)

    return s

def update(bit,n,i,v):
    i+=1

    while i<=n:
        bit[i]+=v
        i+=i&(-i)


def modInverse(b,m):
    g = math.gcd(b, m)
    if (g != 1):
        return -1
    else:
        return pow(b, m - 2, m)

def primeFactors(n):

    sa = []
    # sa.add(n)
    while n % 2 == 0:
        sa.append(2)
        n = n // 2


    for i in range(3,int(math.sqrt(n))+1,2):


        while n % i== 0:
            sa.append(i)
            n = n // i

    # sa.add(n)
    if n > 2:
        sa.append(n)
    return sa


def seive(n):

    pri = [True]*(n+1)
    p = 2
    while p*p<=n:

        if pri[p] == True:

            for i in range(p*p,n+1,p):
                pri[i] = False

        p+=1

    return pri

def check_prim(n):

    if n<0:
        return False
    for i in range(2,int(sqrt(n))+1):
        if n%i == 0:
            return False

    return True


def getZarr(string, z):
    n = len(string)

    # [L,R] make a window which matches
    # with prefix of s
    l, r, k = 0, 0, 0
    for i in range(1, n):

        # if i>R nothing matches so we will calculate.
        # Z[i] using naive way.
        if i > r:
            l, r = i, i

            # R-L = 0 in starting, so it will start
            # checking from 0'th index. For example,
            # for "ababab" and i = 1, the value of R
            # remains 0 and Z[i] becomes 0. For string
            # "aaaaaa" and i = 1, Z[i] and R become 5
            while r < n and string[r - l] == string[r]:
                r += 1
            z[i] = r - l
            r -= 1
        else:

            # k = i-L so k corresponds to number which
            # matches in [L,R] interval.
            k = i - l

            # if Z[k] is less than remaining interval
            # then Z[i] will be equal to Z[k].
            # For example, str = "ababab", i = 3, R = 5
            # and L = 2
            if z[k] < r - i + 1:
                z[i] = z[k]

                # For example str = "aaaaaa" and i = 2,
            # R is 5, L is 0
            else:

                # else start from R and check manually
                l = i
                while r < n and string[r - l] == string[r]:
                    r += 1
                z[i] = r - l
                r -= 1

def search(text, pattern):

    # Create concatenated string "P$T"
    concat = pattern + "$" + text
    l = len(concat)


    z = [0] * l
    getZarr(concat, z)

    ha = []
    for i in range(l):


        if z[i] == len(pattern):
            ha.append(i - len(pattern) - 1)


    return ha


# n,k = map(int,input().split())
# l = list(map(int,input().split()))

#
# n = int(input())
# l = list(map(int,input().split()))
#
# hash = defaultdict(list)
# la = []
#
# for i in range(n):
#     la.append([l[i],i+1])
#
# la.sort(key = lambda x: (x[0],-x[1]))
# ans = []
# r = n
# flag = 0
# lo = []
# ha = [i for i in range(n,0,-1)]
# yo = []
# for a,b in la:
#
#    if a == 1:
#        ans.append([r,b])
#        # hash[(1,1)].append([b,r])
#        lo.append((r,b))
#        ha.pop(0)
#        yo.append([r,b])
#        r-=1
#
#    elif a == 2:
#        # print(yo,lo)
#        # print(hash[1,1])
#        if lo == []:
#            flag = 1
#            break
#        c,d = lo.pop(0)
#        yo.pop(0)
#        if b>=d:
#            flag = 1
#            break
#        ans.append([c,b])
#        yo.append([c,b])
#
#
#
#    elif a == 3:
#
#            if yo == []:
#                flag = 1
#                break
#            c,d = yo.pop(0)
#            if b>=d:
#                flag = 1
#                break
#            if ha == []:
#                flag = 1
#                break
#
#            ka = ha.pop(0)
#
#            ans.append([ka,b])
#            ans.append([ka,d])
#            yo.append([ka,b])
#
# if flag:
#     print(-1)
# else:
#     print(len(ans))
#     for a,b in ans:
#         print(a,b)
def mergeIntervals(arr):

    # Sorting based on the increasing order
    # of the start intervals
    arr.sort(key = lambda x: x[0])

    # array to hold the merged intervals
    m = []
    s = -10000
    max = -100000
    for i in range(len(arr)):
        a = arr[i]
        if a[0] > max:
            if i != 0:
                m.append([s,max])
            max = a[1]
            s = a[0]
        else:
            if a[1] >= max:
                max = a[1]

    #'max' value gives the last point of
    # that particular interval
    # 's' gives the starting point of that interval
    # 'm' array contains the list of all merged intervals

    if max != -100000 and [s, max] not in m:
        m.append([s, max])
    return m
class SortedList:
    def __init__(self, iterable=[], _load=200):
        """Initialize sorted list instance."""
        values = sorted(iterable)
        self._len = _len = len(values)
        self._load = _load
        self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
        self._list_lens = [len(_list) for _list in _lists]
        self._mins = [_list[0] for _list in _lists]
        self._fen_tree = []
        self._rebuild = True

    def _fen_build(self):
        """Build a fenwick tree instance."""
        self._fen_tree[:] = self._list_lens
        _fen_tree = self._fen_tree
        for i in range(len(_fen_tree)):
            if i | i + 1 < len(_fen_tree):
                _fen_tree[i | i + 1] += _fen_tree[i]
        self._rebuild = False

    def _fen_update(self, index, value):
        """Update `fen_tree[index] += value`."""
        if not self._rebuild:
            _fen_tree = self._fen_tree
            while index < len(_fen_tree):
                _fen_tree[index] += value
                index |= index + 1

    def _fen_query(self, end):
        """Return `sum(_fen_tree[:end])`."""
        if self._rebuild:
            self._fen_build()

        _fen_tree = self._fen_tree
        x = 0
        while end:
            x += _fen_tree[end - 1]
            end &= end - 1
        return x

    def _fen_findkth(self, k):
        """Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
        _list_lens = self._list_lens
        if k < _list_lens[0]:
            return 0, k
        if k >= self._len - _list_lens[-1]:
            return len(_list_lens) - 1, k + _list_lens[-1] - self._len
        if self._rebuild:
            self._fen_build()

        _fen_tree = self._fen_tree
        idx = -1
        for d in reversed(range(len(_fen_tree).bit_length())):
            right_idx = idx + (1 << d)
            if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
                idx = right_idx
                k -= _fen_tree[idx]
        return idx + 1, k

    def _delete(self, pos, idx):
        """Delete value at the given `(pos, idx)`."""
        _lists = self._lists
        _mins = self._mins
        _list_lens = self._list_lens

        self._len -= 1
        self._fen_update(pos, -1)
        del _lists[pos][idx]
        _list_lens[pos] -= 1

        if _list_lens[pos]:
            _mins[pos] = _lists[pos][0]
        else:
            del _lists[pos]
            del _list_lens[pos]
            del _mins[pos]
            self._rebuild = True

    def _loc_left(self, value):
        """Return an index pair that corresponds to the first position of `value` in the sorted list."""
        if not self._len:
            return 0, 0

        _lists = self._lists
        _mins = self._mins

        lo, pos = -1, len(_lists) - 1
        while lo + 1 < pos:
            mi = (lo + pos) >> 1
            if value <= _mins[mi]:
                pos = mi
            else:
                lo = mi

        if pos and value <= _lists[pos - 1][-1]:
            pos -= 1

        _list = _lists[pos]
        lo, idx = -1, len(_list)
        while lo + 1 < idx:
            mi = (lo + idx) >> 1
            if value <= _list[mi]:
                idx = mi
            else:
                lo = mi

        return pos, idx

    def _loc_right(self, value):
        """Return an index pair that corresponds to the last position of `value` in the sorted list."""
        if not self._len:
            return 0, 0

        _lists = self._lists
        _mins = self._mins

        pos, hi = 0, len(_lists)
        while pos + 1 < hi:
            mi = (pos + hi) >> 1
            if value < _mins[mi]:
                hi = mi
            else:
                pos = mi

        _list = _lists[pos]
        lo, idx = -1, len(_list)
        while lo + 1 < idx:
            mi = (lo + idx) >> 1
            if value < _list[mi]:
                idx = mi
            else:
                lo = mi

        return pos, idx

    def add(self, value):
        """Add `value` to sorted list."""
        _load = self._load
        _lists = self._lists
        _mins = self._mins
        _list_lens = self._list_lens

        self._len += 1
        if _lists:
            pos, idx = self._loc_right(value)
            self._fen_update(pos, 1)
            _list = _lists[pos]
            _list.insert(idx, value)
            _list_lens[pos] += 1
            _mins[pos] = _list[0]
            if _load + _load < len(_list):
                _lists.insert(pos + 1, _list[_load:])
                _list_lens.insert(pos + 1, len(_list) - _load)
                _mins.insert(pos + 1, _list[_load])
                _list_lens[pos] = _load
                del _list[_load:]
                self._rebuild = True
        else:
            _lists.append([value])
            _mins.append(value)
            _list_lens.append(1)
            self._rebuild = True

    def discard(self, value):
        """Remove `value` from sorted list if it is a member."""
        _lists = self._lists
        if _lists:
            pos, idx = self._loc_right(value)
            if idx and _lists[pos][idx - 1] == value:
                self._delete(pos, idx - 1)

    def remove(self, value):
        """Remove `value` from sorted list; `value` must be a member."""
        _len = self._len
        self.discard(value)
        if _len == self._len:
            raise ValueError('{0!r} not in list'.format(value))

    def pop(self, index=-1):
        """Remove and return value at `index` in sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        value = self._lists[pos][idx]
        self._delete(pos, idx)
        return value

    def bisect_left(self, value):
        """Return the first index to insert `value` in the sorted list."""
        pos, idx = self._loc_left(value)
        return self._fen_query(pos) + idx

    def bisect_right(self, value):
        """Return the last index to insert `value` in the sorted list."""
        pos, idx = self._loc_right(value)
        return self._fen_query(pos) + idx

    def count(self, value):
        """Return number of occurrences of `value` in the sorted list."""
        return self.bisect_right(value) - self.bisect_left(value)

    def __len__(self):
        """Return the size of the sorted list."""
        return self._len

    def __getitem__(self, index):
        """Lookup value at `index` in sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        return self._lists[pos][idx]

    def __delitem__(self, index):
        """Remove value at `index` from sorted list."""
        pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
        self._delete(pos, idx)

    def __contains__(self, value):
        """Return true if `value` is an element of the sorted list."""
        _lists = self._lists
        if _lists:
            pos, idx = self._loc_left(value)
            return idx < len(_lists[pos]) and _lists[pos][idx] == value
        return False

    def __iter__(self):
        """Return an iterator over the sorted list."""
        return (value for _list in self._lists for value in _list)

    def __reversed__(self):
        """Return a reverse iterator over the sorted list."""
        return (value for _list in reversed(self._lists) for value in reversed(_list))

    def __repr__(self):
        """Return string representation of sorted list."""
        return 'SortedList({0})'.format(list(self))

def ncr(n, r, p):

    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
                      p - 2, p)) % p


def sol(n):

    seti = set()
    for i in range(1,int(sqrt(n))+1):
        if n%i == 0:
            seti.add(n//i)
            seti.add(i)


    return seti
def lcm(a,b):

    return (a*b)//gcd(a,b)





#
# n,p = map(int,input().split())
#
# s = input()
#
# if n <=2:
#     if n == 1:
#         pass
#     if n == 2:
#         pass
# i = n-1
# idx = -1
# while i>=0:
#     z = ord(s[i])-96
#     k = chr(z+1+96)
#     flag = 1
#     if i-1>=0:
#         if s[i-1]!=k:
#             flag+=1
#     else:
#             flag+=1
#     if i-2>=0:
#         if s[i-2]!=k:
#             flag+=1
#     else:
#         flag+=1
#     if flag == 2:
#         idx = i
#         s[i] = k
#         break
# if idx == -1:
#     print('NO')
#     exit()
# for i in range(idx+1,n):
#     if
#

def moore_voting(l):

    count1 = 0
    count2 = 0
    first = 10**18
    second = 10**18
    n = len(l)
    for i in range(n):

        if l[i] == first:
            count1+=1
        elif l[i] == second:
            count2+=1

        elif count1 == 0:
            count1+=1
            first = l[i]

        elif count2 == 0:
            count2+=1
            second = l[i]
        else:
            count1-=1
            count2-=1

    for i in range(n):
        if l[i] == first:
            count1+=1
        elif l[i] == second:
            count2+=1
    if count1>n//3:
        return first
    if count2>n//3:
        return second

    return -1





def find_parent(u,parent):

    if u!=parent[u]:
        parent[u] = find_parent(parent[u],parent)

    return parent[u]






def dis_union(n,e):


    par = [i for i in range(n+1)]
    rank = [1]*(n+1)

    for a,b in e:

        z1,z2 = find_parent(a,par),find_parent(b,par)
        if rank[z1]>rank[z2]:
            z1,z2 = z2,z1
        if z1!=z2:
            par[z1] = z2
            rank[z2]+=rank[z1]
        else:
            return a,b


def dijkstra(n,tot,hash):


    hea = [[0,n]]
    dis = [10**18]*(tot+1)
    dis[n] = 0
    boo = defaultdict(bool)
    check = defaultdict(int)
    while hea:
        a,b = heapq.heappop(hea)

        if boo[b]:
            continue

        boo[b] = True

        for i,w in hash[b]:
            if b == 1:
              c = 0
              if (1,i,w) in nodes:
                 c = nodes[(1,i,w)]
                 del nodes[(1,i,w)]

              if dis[b]+w<dis[i]:
                dis[i] = dis[b]+w

                check[i] = c

              elif dis[b]+w == dis[i] and c == 0:
                  dis[i] = dis[b]+w
                  check[i] = c

            else:

                if dis[b]+w<=dis[i]:
                    dis[i] = dis[b]+w
                    check[i] = check[b]



            heapq.heappush(hea,[dis[i],i])

    return check

def power(x,y,p):

    res = 1
    x = x%p
    if x == 0:
        return 0

    while y>0:

        if (y&1) == 1:
            res*=x

        x = x*x
        y = y>>1

    return res
import sys
from math import ceil,log2

INT_MAX = sys.maxsize


def minVal(x, y) :
    return x if (x < y) else y


def getMid(s, e) :
    return s + (e - s) // 2


def RMQUtil( st, ss, se, qs, qe, index) :


    if (qs <= ss and qe >= se) :
        return st[index]


    if (se < qs or ss > qe) :
        return INT_MAX


    mid = getMid(ss, se)
    return minVal(RMQUtil(st, ss, mid, qs,
                          qe, 2 * index + 1),
                  RMQUtil(st, mid + 1, se,
                          qs, qe, 2 * index + 2))


def RMQ( st, n, qs, qe) :


    if (qs < 0 or qe > n - 1 or qs > qe) :

        print("Invalid Input")
        return -1

    return RMQUtil(st, 0, n - 1, qs, qe, 0)


def constructSTUtil(arr, ss, se, st, si) :


    if (ss == se) :

        st[si] = arr[ss]
        return arr[ss]


    mid = getMid(ss, se)
    st[si] = minVal(constructSTUtil(arr, ss, mid,
                                    st, si * 2 + 1),
                    constructSTUtil(arr, mid + 1, se,
                                    st, si * 2 + 2))

    return st[si]

def constructST( arr, n) :


    x = (int)(ceil(log2(n)))


    max_size = 2 * (int)(2**x) - 1

    st = [0] * (max_size)


    constructSTUtil(arr, 0, n - 1, st, 0)


    return st

# t = int(input())
# for _ in range(t):
#
#  n = int(input())
#  l = list(map(int,input().split()))
#  # x,y = 0,10
#  st = constructST(l, n)
#
#  pre = [0]
#  suf = [0]
#  for i in range(n):
#      pre.append(max(pre[-1],l[i]))
#  for i in range(n-1,-1,-1):
#      suf.append(max(suf[-1],l[i]))
#
#
#  i = 1
#  # print(pre,suf)
#  flag = 0
#  x,y,z = -1,-1,-1
#  # suf.reverse()
#  print(suf)
#  while i<len(pre):
#
#      z = pre[i]
#      j = bisect_left(suf,z)
#      if suf[j] == z:
#          while i<n and l[i]<=z:
#              i+=1
#              if pre[i]>z:
#                  break
#          while j<n and l[n-j]<=z:
#              j+=1
#              if suf[j]>z:
#                  break
#          # j-=1
#          print(i,n-j)
#          # break/
#          if RMQ(st,n,i,j) == z:
#              c = i+j-i+1
#              x,y,z = i,j-i+1,n-c
#              break
#          else:
#              i+=1
#
#      else:
#          i+=1
#
#
#
#  if x!=-1:
#   print('Yes')
#   print(x,y,z)
#  else:
#      print('No')



# t = int(input())
#
# for _ in range(t):
#

# def debug(n):
#     ans = []
#     for i in range(1,n+1):
#         for j in range(i+1,n+1):
#             if (i*(j+1))%(j-i) == 0 :
#                 ans.append([i,j])
#     return ans
#
#
# n = int(input())
# print(debug(n))

# import sys
# input = sys.stdin.readline
# import bisect
#
# t=int(input())
# for tests in range(t):
#     n=int(input())
#     A=list(map(int,input().split()))
#
#     LEN = len(A)
#     Sparse_table = [A]
#
#     for i in range(LEN.bit_length()-1):
#         j = 1<<i
#         B = []
#         for k in range(len(Sparse_table[-1])-j):
#             B.append(min(Sparse_table[-1][k], Sparse_table[-1][k+j]))
#         Sparse_table.append(B)
#
#     def query(l,r): # [l,r)におけるminを求める.
#         i=(r-l).bit_length()-1 # 何番目のSparse_tableを見るか.
#
#         return min(Sparse_table[i][l],Sparse_table[i][r-(1<<i)]) # (1<<i)個あれば[l, r)が埋まるので, それを使ってminを求める.
#
#     LMAX=[A[0]]
#     for i in range(1,n):
#         LMAX.append(max(LMAX[-1],A[i]))
#
#     RMAX=A[-1]
#
#     for i in range(n-1,-1,-1):
#         RMAX=max(RMAX,A[i])
#
#         x=bisect.bisect(LMAX,RMAX)
#         #print(RMAX,x)
#         print(RMAX,x,i)
#         if x==0:
#             continue
#
#         v=min(x,i-1)
#         if v<=0:
#             continue
#
#         if LMAX[v-1]==query(v,i)==RMAX:
#             print("YES")
#             print(v,i-v,n-i)
#             break
#
#         v-=1
#         if v<=0:
#             continue
#         if LMAX[v-1]==query(v,i)==RMAX:
#             print("YES")
#             print(v,i-v,n-i)
#             break
#     else:
#         print("NO")
#
#
#
#
#







#
#
#
#
# t = int(input())
#
# for _ in range(t):
#
#     x = int(input())
#     mini = 10**18
#     n = ceil((-1 + sqrt(1+8*x))/2)
#     for i in range(-100,1):
#         z = x+-1*i
#         z1 = (abs(i)*(abs(i)+1))//2
#         z+=z1
#         # print(z)
#         n = ceil((-1 + sqrt(1+8*z))/2)
#
#         y = (n*(n+1))//2
#         # print(n,y,z,i)
#         mini = min(n+y-z,mini)
#         print(n+y-z,i)
#
#
#     print(mini)
#






#
#
# n,m = map(int,input().split())
# l = []
# hash = defaultdict(int)
# for i in range(n):
#     la = list(map(int,input().split()))[1:]
#     l.append(set(la))
#     # for i in la:
#     #     hash[i]+=1
#
# for i in range(n):
#
#     for j in range(n):
#         if i!=j:
#
#            if len(l[i].intersection(l[j])) == 0:
#                for k in range(n):
#
#
#            else:
#                break
#
#
#
#
#
#

# practicing segment_trees

# t = int(input())
#
# for _ in range(t):
#     n = int(input())
#     l = []
#     for i in range(n):
#         a,b = map(int,input().split())
#         l.append([a,b])
#
#     l.sort()

# n,m = map(int,input().split())
# l = list(map(int,input().split()))
#
# hash = defaultdict(int)
# for i in range(1,2**n,2):
#     count = 0
#     z1 = bin(l[i]|l[i-1])[2:]
#     z1+='0'*(17-len(z1)) + z1
#     for k in range(len(z1)):
#         if z1[k] == '1':
#             hash[k]+=1
# for i in range(m):
#     a,b = map(int,input().split())
#     a-=1
#     init = a
#     if a%2 == 0:
#         a+=1
#     z1 = bin(l[a]|l[a-1])[2:]
#     z1+='0'*(17-len(z1)) + z1
#     for k in range(len(z1)):
#         if z1[k] == '1':
#             hash[k]-=1
#     l[init] = b
#     a = init
#     if a%2 == 0:
#         a+=1
#     z1 = bin(l[a]|l[a-1])[2:]
#     z1+='0'*(17-len(z1)) + z1
#     for k in range(len(z1)):
#         if z1[k] == '1':
#             hash[k]+=1
#     ans = ''
#     for k in range(17):
#         if n%2 == 0:
#             if hash[k]%2 == 0:
#                 ans+='0'
#             else:
#                 ans+='1'
#         else:
#             if hash[k]%2 == 0:
#                 if hash[k]
#
#
#
def bfs1(p):
    level = [10**18]*(n+1)
    boo = [False]*(n+1)
    par = [i for i in range(n+1)]
    queue = [p]
    boo[p] = True
    level[p] = 0



    while queue:
        z = queue.pop(0)

        for i in hash[z]:
            if not boo[i]:

                boo[i] = True
                queue.append(i)
                level[i] = level[z]+1
                par[i] = z
    return par,level

n = int(input())
l = list(map(int,input().split()))
hash = defaultdict(int)
for i in l:
    hash[i]+=1
k = list(set(l))

k.sort()
ans = []
for i in k[::-1]:

    if len(ans) == n:
        break

    z1 = 0
    if hash[i] == 0:
        continue
    z2 = 0
    for j in ans:
        if gcd(j,i) == i:
            z1+=1
        
        
    # if i == 3:
    #         print(ans,z1)





    z = -2*z1+sqrt((2*z1)**2+4*hash[i])
    
    z//=2
    for j in ans:
        if z>0:
         hash[gcd(i,j)]-=2*z
    for j in range(int(z)):
            ans.append(i)
    
    






print(*ans)