def gdc(a, b): if b == 0: return a else: return gdc(b, a % b) if __name__ == '__main__': N = int(input()) a = list(map(int, input().split())) for i in range(N - 1): idx = 0 low_value = 999999 for j in range(i + 1, N): d = gdc(a[i], a[j]) lcm = a[i] / d * a[j] if(low_value > lcm): low_value = lcm idx = j temp = a[i + 1] a[i + 1] = a[idx] a[idx] = temp print(' '.join(map(str,a)))