import itertools import sys import itertools input = sys.stdin.readline def main(): N = int(input()) *A, = map(int, input().split()) MAX = 10000 cnt = [0]*(MAX+1) for a in A[1:]: cnt[a] += 1 ptr = list(range(MAX+1)) def getnxt(x): while ptr[x] <= MAX and cnt[ptr[x]] == 0: ptr[x] += x return ptr[x] def getmin(v): maxv = ans = MAX * MAX for i in itertools.count(1): if v % i == 0: n = getnxt(i) l = n * (v // i) if maxv > l: maxv = l ans = n elif maxv == l: ans = min(ans, n) n = getnxt(v // i) l = n * i if maxv > l: maxv = l ans = n elif maxv == l: ans = min(ans, n) if i*i > v: return ans ans = [A[0]] while len(ans) != N: ret = getmin(ans[-1]) ans += [ret]*cnt[ret] cnt[ret] = 0 print(*ans, sep=' ') if __name__ == '__main__': main()