from math import gcd import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def lcm(x,y): return x*y//gcd(x,y) N=int(input()) A=list(map(int,input().split())) ANS=[A[0]] X=sorted(A[1:]) USE=[0]*(N-1) for tests in range(N-1): a=ANS[-1] MIN=1<<30 now=-1 for i in range(N-1): if USE[i]==1: continue k=lcm(a,X[i]) if k=MIN: break ANS.append(X[now]) USE[now]=1 print(*ANS)