import java.io.*; import java.util.*; public class Main_yukicoder14 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int[] cnt = new int[10000 + 1]; PriorityQueue pq = new PriorityQueue<>(); List ret = new ArrayList<>(); for (int i = 0; i < n; i++) { int a = sc.nextInt(); if (i > 0) { cnt[a]++; pq.add(a); } else { ret.add(a); } } out: while (!pq.isEmpty()) { int e = pq.peek(); if (cnt[e] <= 0) { pq.remove(); continue; } int prev = ret.get(ret.size() - 1); SortedSet ts = new TreeSet<>(); for (int i = 1; i * i <= prev; i++) { if (prev % i == 0) { ts.add(i); ts.add(prev / i); } } int lcm = lcm(prev, e); for (int j = 1; prev * j <= lcm; j++) { for (int d : ts) { if (d * j > 10000) { break; } if (cnt[d * j] > 0 && lcm(prev, d * j) == prev * j) { ret.add(d * j); cnt[d * j]--; continue out; } } } } // pr.println(ret); // pr.flush(); for (int i = 0; i < n; i++) { pr.print(ret.get(i)); if (i < n - 1) { pr.print(" "); } else { pr.println(); } } pr.close(); sc.close(); } private static int lcm(int n, int m) { return n / gcd(n, m) * m; } private static int gcd(int n, int m) { if (m == 0) { return n; } else { return gcd(m, n % m); } } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }