# -*- coding: utf-8 -*- inf = 1e9 def gcd(p, q): if q == 0: return p return gcd(q, p % q) def lcm(p, q): return p / gcd(p, q) * q N = input() A = map(int, raw_input().split()) S = [[] for i in xrange(10001)] div = [[] for i in xrange(N)] for i in xrange(N): j = 1 while j * j <= A[i]: if A[i] % j == 0: div[i].append(j) S[j].append([A[i], i]) if j * j != A[i]: div[i].append(A[i] / j) S[A[i] / j].append([A[i], i]) j += 1 for i in xrange(len(S)): S[i].sort() vis = [0] * N ans = [A[0]] ind = 0 for i in xrange(N - 1): num = ans[i] vis[ind] = 1 m = (inf, 0, 0) for j in div[ind]: while len(S[j]) and vis[S[j][0][1]]: S[j].pop(0) if len(S[j]): m = min(m, (lcm(num, S[j][0][0]), S[j][0][0], S[j][0][1])) ans.append(m[1]) ind = m[2] print " ".join(map(str, ans))