#include <bits/stdc++.h>
using namespace std;
const long long N = 3000001;
const long long MOD = 1000000007;
const long long INF = LLONG_MAX;
void COUT(vector<long long> v) {
  for (auto it : v) cout << it << ' ';
  cout << '\n';
}
vector<long long> prime;
vector<bool> mark(N);
void seive() {
  mark[0] = mark[1] = true;
  for (int i = 4; i <= N; i += 2) mark[i] = true;
  for (int i = 2; i * i <= N; i++)
    if (!mark[i])
      for (int j = i * i; j <= N; j += (2 * i)) mark[j] = true;
  prime.push_back(2LL);
  for (int i = 3; i <= N; i += 2)
    if (!mark[i]) prime.push_back(i);
}
long long getdiv(long long x) {
  for (auto it : prime)
    if (x % it == 0) return (x / it);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  seive();
  int t = 1;
  while (t--) {
    long long n, i, j;
    cin >> n;
    vector<long long> p, np, res;
    map<long long, long long> make_pair;
    for (i = 0; i < 2 * n; i++) {
      long long a;
      cin >> a;
      if (mark[a])
        np.push_back(a);
      else
        p.push_back(a);
      make_pair[a]++;
    }
    sort(np.rbegin(), np.rend());
    for (auto it : np) {
      long long temp = getdiv(it);
      if (make_pair[it] && make_pair[temp]) {
        res.push_back(it);
        make_pair[it]--;
        make_pair[temp]--;
      }
    }
    sort(p.begin(), p.end());
    for (auto it : p) {
      if (make_pair[it] && make_pair[prime[it - 1]]) {
        res.push_back(it);
        make_pair[it]--;
        make_pair[prime[it - 1]]--;
      }
    }
    COUT(res);
  }
}
