from collections import Counter N = int(input()) A = tuple(map(int, input().split())) MAX = 10000 divisors = [[] for _ in range(MAX + 1)] for i in range(1, MAX + 1): for j in range(i, MAX + 1, i): divisors[j].append(i) ct = Counter(A) multiple = [[] for _ in range(MAX + 1)] for a in sorted(ct.keys(), reverse=True): for x in divisors[a]: multiple[x].append(a) cur = A[0] ans = [] while len(ans) < N: ans.append(cur) ct[cur] -= 1 next_cur = 0 tmp_lcm_min = MAX ** 2 for x in divisors[cur]: while multiple[x] and not ct[multiple[x][-1]]: multiple[x].pop() if multiple[x]: tmp_next_cur = multiple[x][-1] if tmp_lcm_min > tmp_next_cur // x: tmp_lcm_min = tmp_next_cur // x next_cur = tmp_next_cur cur = next_cur print(*ans)