#include <bits/stdc++.h>
int solve();
int main(int argc, char* argv[]) {
  solve();
  return 0;
}
static const int N = (1 << 18);
static const int P = (2750131) + 1;
int solve() {
  std::vector<unsigned char> mask(P);
  std::vector<int> max_divs(P);
  mask[0] = mask[1] = 1;
  int nprimes = 0;
  for (int i = 2; i < P; i++) {
    if (!mask[i]) {
      ++nprimes;
      max_divs[i] = 1;
      if (i < 10000) {
        for (int j = i * i; j < P; j += i) {
          if (!mask[j]) {
            mask[j] = 1;
            max_divs[j] = j / i;
          }
        }
      }
    }
  }
  int n;
  (void)scanf("%d", &n);
  std::vector<int> cnt_a(P);
  for (int i = 0; i < n * 2; ++i) {
    int x;
    (void)scanf("%d", &x);
    assert(x > 1 && x < P);
    ++cnt_a[x];
  }
  std::vector<int> a;
  for (int i = P - 1, m = nprimes + 1; i >= 2; --i) {
    m -= !mask[i];
    if (!cnt_a[i]) {
      continue;
    }
    bool is_prime = !mask[i];
    if (is_prime) {
      bool is_m_prime = !mask[m];
      while (cnt_a[i] > 0 && cnt_a[m] > 0) {
        a.push_back(m);
        --cnt_a[i];
        --cnt_a[m];
      }
      assert(cnt_a[i] == 0);
    } else {
      int d = max_divs[i];
      while (cnt_a[i] > 0 && cnt_a[d] > 0) {
        a.push_back(i);
        --cnt_a[i];
        --cnt_a[d];
      }
      assert(cnt_a[i] == 0);
    }
  }
  assert(a.size() == n);
  for (int i = 0; i < n; ++i) {
    printf("%d ", a[i]);
  }
  printf("\n");
  return 0;
}
