#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e6 + 5;
bool mark[N + 5];
int save[N + 5];
vector<int> Prime;
int bal[N], f[N];
void seive() {
  for (int i = 2; i < N; i++) {
    if (mark[i]) {
      continue;
    }
    for (int j = 2 * i; j < N; j += i) {
      mark[j] = 1;
    }
  }
  Prime.push_back(2);
  for (int i = 3; i < N; i += 2) {
    if (mark[i]) {
      continue;
    }
    Prime.push_back(i);
  }
  for (int i = 0; i < Prime.size(); i++) {
    save[Prime[i]] = i + 1;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  seive();
  int n;
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    bal[x]++;
    if (!mark[x]) {
      f[x] = 1;
      continue;
    }
    for (int i = 2; i * i <= x; i++) {
      if (x % i) {
        continue;
      }
      f[x] = max(i, x / i);
      break;
    }
  }
  vector<int> ans;
  for (int i = N - 5; i >= 0; i--) {
    while (bal[i]--) {
      if (mark[i] == 0) {
        int lol = save[i];
        ans.push_back(lol);
        --bal[lol];
      } else {
        int lol = f[i];
        ans.push_back(i);
        --bal[lol];
      }
    }
  }
  n /= 2;
  assert(ans.size() == n);
  for (auto it = ans.begin(); it != ans.end(); it++) {
    cout << *it << " ";
  }
  cout << "\n";
  return 0;
}
