#include <bits/stdc++.h>
using namespace std;
const long long N = 2750131 + 1;
bool ver[N];
vector<long long> p;
long long spf[N];
void sieve() {
  p.push_back(-1);
  memset(ver, false, sizeof(ver));
  for (long long i = 2; i < N; i++) spf[i] = i;
  for (long long i = 2; i < N; i++) {
    if (!ver[i]) {
      p.push_back(i);
      for (long long j = i * i; j < N; j += i) {
        ver[j] = true;
        spf[j] = min(spf[j], i);
      }
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  sieve();
  long long n;
  cin >> n;
  long long b[2 * n];
  vector<long long> a;
  map<long long, long long> q[2];
  for (long long i = 0; i < 2 * n; i++) {
    cin >> b[i];
    q[ver[b[i]]][b[i]]++;
  }
  auto it = q[1].rbegin();
  while (!q[1].empty()) {
    it = q[1].rbegin();
    long long val = (*it).first;
    long long fre = (*it).second;
    long long big = val / spf[val];
    long long big_fre = q[ver[big]][big];
    long long cons = min(fre, big_fre);
    q[1][val] -= cons;
    q[ver[big]][big] -= cons;
    if (q[1][val] == 0) {
      q[1].erase(val);
    }
    if (q[ver[big]][big] == 0) {
      q[ver[big]].erase(big);
    }
    for (long long i = 0; i < cons; i++) {
      a.push_back(val);
    }
  }
  auto it1 = q[0].begin();
  while (!q[0].empty()) {
    it1 = q[0].begin();
    long long val = (*it1).first;
    long long fre = (*it1).second;
    long long big = p[val];
    long long big_fre = q[ver[big]][big];
    long long cons = min(fre, big_fre);
    q[0][val] -= cons;
    q[ver[big]][big] -= cons;
    if (q[0][val] == 0) {
      q[0].erase(val);
    }
    if (q[ver[big]][big] == 0) {
      q[ver[big]].erase(big);
    }
    for (long long i = 0; i < cons; i++) a.push_back(val);
  }
  for (long long x : a) cout << x << " ";
}
