#include <bits/stdc++.h>
using namespace std;
vector<long long> isprime(2750132, true);
vector<long long> prime;
vector<long long> SPF(2750132);
int main() {
  int n;
  scanf("%d", &n);
  isprime[0] = isprime[1] = false;
  for (long long int i = 2; i < 2750132; i++) {
    if (isprime[i]) {
      prime.push_back(i);
      SPF[i] = i;
    }
    for (long long int j = 0;
         j < (int)prime.size() && i * prime[j] < 2750132 && prime[j] <= SPF[i];
         j++) {
      isprime[i * prime[j]] = false;
      SPF[i * prime[j]] = prime[j];
    }
  }
  multiset<int> primevals;
  multiset<int> composites;
  int final_arr[2 * n];
  for (int k = 0; k < 2 * n; k++) {
    scanf("%d", &final_arr[k]);
    if (isprime[final_arr[k]])
      primevals.insert(final_arr[k]);
    else
      composites.insert(final_arr[k]);
  }
  multiset<int>::reverse_iterator it = composites.rbegin();
  while (it != composites.rend()) {
    for (int k = 2; k <= sqrt(*it); k++) {
      if (*it % k == 0) {
        int val = *it / k;
        if (isprime[val] && primevals.find(val) != primevals.end()) {
          primevals.erase(primevals.equal_range(val).first);
          break;
        } else if (composites.find(val) != composites.end()) {
          composites.erase(composites.equal_range(val).first);
          break;
        }
      }
    }
    it++;
  }
  multiset<int>::iterator it1 = primevals.begin();
  while (it1 != primevals.end()) {
    if (primevals.find(prime[*it1 - 1]) != primevals.end()) {
      primevals.erase(primevals.equal_range(prime[*it1 - 1]).first);
    }
    it1++;
  }
  multiset<int>::iterator it2 = primevals.begin();
  while (it2 != primevals.end()) {
    cout << *it2 << ' ';
    it2++;
  }
  multiset<int>::iterator it3 = composites.begin();
  while (it3 != composites.end()) {
    cout << *it3 << ' ';
    it3++;
  }
}
