import fractions import heapq def lcm(a, b): return a / fractions.gcd(a, b) * b MAX_A = 10000 N = input() A = map(int, raw_input().split()) divisor = [[] for _ in xrange(N)] queue = [[] for _ in xrange(MAX_A + 1)] used = [False] * N for i, a in enumerate(A): j = 1 while j * j <= a: if a % j == 0: divisor[i].append(j) heapq.heappush(queue[j], (a, i)) if a / j != j: divisor[i].append(a / j) heapq.heappush(queue[a / j], (a, i)) j += 1 ans = range(N) for i in xrange(N - 1): index = ans[i] used[index] = True best = (float("inf"), -1, -1) for d in divisor[index]: que = queue[d] while que: tmp = que[0] if used[tmp[1]]: heapq.heappop(que) continue best = min(best, (lcm(A[index], tmp[0]), tmp[0], tmp[1])) break ans[i + 1] = best[2] print ' '.join(map(lambda index: str(A[index]), ans))