package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	total = 2750131 + 8
)

var primos [total]int
var indices [total]int
var repeticionesIn [total]int

func init() {
	for i := 0; i < total; i++ {
		primos[i] = i
	}
}

//SieveOfEratosthenes of earth
func SieveOfEratosthenes(limite int) {

	for i := 2; i < limite; i++ {

		if primos[i] != i {
			primos[i] = i / primos[i]
			continue
		}
		for j := i * i; j < limite && j > 0; j += i {
			if j > len(primos) {

			}
			primos[j] = i
		}
	}

}

func main() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("hola3")
		}
	}()

	SieveOfEratosthenes(total)

	r := make([]int, 0)

	for i, count := 1, 0; i < total; i++ {
		if primos[i] == i {
			indices[i] = count
			count++
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	maxCap := 512 * 1024
	buff := make([]byte, maxCap)
	sc.Buffer(buff, maxCap)
	sc.Scan()
	sc.Text()
	sc.Scan()
	input := strings.Fields(sc.Text())
	for i := 0; i < len(input); i++ {
		val, _ := strconv.Atoi(input[i])
		repeticionesIn[val]++
	}

	for i := total - 1; i >= 0; i-- {
		for repeticionesIn[i] > 0 {
			if i == primos[i] {
				repeticionesIn[indices[i]]--
				r = append(r, indices[i])
			} else {
				repeticionesIn[primos[i]]--
				r = append(r, i)
			}
			repeticionesIn[i]--
		}
	}
	fmt.Print(r[0])
	for i := 1; i < len(r); i++ {
		fmt.Printf(" %d", r[i])
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	total = 2750131 + 8
)

var primos [total]int
var indices [total]int
var repeticionesIn [total]int

func init() {
	for i := 0; i < total; i++ {
		primos[i] = i
	}
}

//Sieve of earth
func SieveOfEratosthenes(limite int) {
	for i := 2; i < limite; i++ {
		if primos[i] != i {
			primos[i] = i / primos[i]
			continue
		}
		for j := i * i; j < limite; j = j + i {
			primos[j] = i
		}
	}

}

func main() {
	SieveOfEratosthenes(total)
	r := make([]int, 0)

	for i, count := 1, 0; i < total; i++ {
		if primos[i] == i {
			indices[i] = count
			count++
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	maxCap := 5120 * 1024
	buff := make([]byte, maxCap)
	sc.Buffer(buff, maxCap)
	sc.Scan()
	sc.Text()
	sc.Scan()
	input := strings.Fields(sc.Text())
	// for i := 0; i < len(input); i++ {
	// 	val, _ := strconv.Atoi(input[i])
	// 	repeticionesIn[val]++
	// }

	// for i := total - 1; i >= 0; i-- {
	// 	for repeticionesIn[i] > 0 {
	// 		if i == primos[i] {
	// 			repeticionesIn[indices[i]]--
	// 			r = append(r, indices[i])
	// 		} else {
	// 			repeticionesIn[primos[i]]--
	// 			r = append(r, i)
	// 		}
	// 		repeticionesIn[i]--
	// 	}
	// }
	// fmt.Print(r[0])
	// for i := 1; i < len(r); i++ {
	// 	fmt.Printf(" %d", r[i])
	// }
	fmt.Println()
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1176D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	const mx = 2750132
	pid := [mx]int{-1, -1}
	lpf := [mx]int{1: 1}
	c := 1
	for i := 2; i < mx; i++ {
		if pid[i] == 0 {
			pid[i] = c
			c++
			for j := 2 * i; j < mx; j += i {
				pid[j] = -1
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}

	cnt := [mx]int{}
	var n, v int
	Fscan(in, &n)
	for i := 0; i < 2*n; i++ {
		Fscan(in, &v)
		cnt[v]++
	}
	ans := make([]interface{}, 0, n)
	for i := mx - 1; i > 0; i-- {
		if c := cnt[i]; c > 0 {
			if p := pid[i]; p > 0 {
				cnt[p] -= c
				ans = append(ans, p)
			} else {
				cnt[i/lpf[i]] -= c
				ans = append(ans, i)
			}
		}
	}
	Fprint(out, ans...)
}

func main() { CF1176D(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1176D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	const mx = 2750132
	id := [mx]int{-1, -1}
	f := [mx]int{1: 1}
	c := 1
	for i := 2; i < mx; i++ {
		if id[i] == 0 {
			id[i] = c
			c++
			for j := 2 * i; j < mx; j += i {
				id[j] = -1
				if f[j] == 0 {
					f[j] = i
				}
			}
		}
	}

	cnt := [mx]int{}
	var n, v int
	Fscan(in, &n)
	for i := 0; i < 2*n; i++ {
		Fscan(in, &v)
		cnt[v]++
	}
	ans := make([]interface{}, 0, n)
	for i := mx - 1; i > 0; i-- {
		if c := cnt[i]; c > 0 {
			v := id[i]
			if v > 0 {
				cnt[v] -= c
			} else {
				cnt[i/f[i]] -= c
				v = i
			}
			for ; c > 0; c-- {
				ans = append(ans, v)
			}
		}
	}
	Fprint(out, ans...)
}

func main() { CF1176D(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1176D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	const mx = 2750132
	pid := [mx]int{-1, -1}
	gpf := [mx]int{1: 1}
	c := 1
	for i := 2; i < mx; i++ {
		if pid[i] == 0 {
			pid[i] = c
			c++
			for j := 2 * i; j < mx; j += i {
				pid[j] = -1
				gpf[j] = i
			}
		}
	}

	cnt := [mx]int{}
	var n, v int
	Fscan(in, &n)
	for i := 0; i < 2*n; i++ {
		Fscan(in, &v)
		cnt[v]++
	}
	ans := make([]interface{}, 0, n)
	for i := mx - 1; i > 0; i-- {
		if c := cnt[i]; c > 0 {
			if p := pid[i]; p > 0 {
				cnt[p] -= c
				ans = append(ans, p)
			} else {
				cnt[gpf[i]] -= c
				ans = append(ans, i)
			}
		}
	}
	Fprint(out, ans...)
}

func main() { CF1176D(os.Stdin, os.Stdout) }


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    input()
    a = []

    b = [int(bi) for bi in input().split()]
    counter = [0] * 2750132
    for bi in b:
        counter[bi] += 1

    primes = prime_list(2750131)
    is_prime = [False] * 2750132
    for pi in primes:
        is_prime[pi] = True

    for bi in b:
        f = largest_factor(bi)
        if f:
            while counter[f] and counter[bi]:
                counter[f] -= 1
                counter[bi] -= 1
                a.append(bi)

    for i, pi in enumerate(primes):
        if is_prime[i]:
            while counter[i] and counter[pi]:
                counter[i] -= 1
                counter[pi] -= 1
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []

    for bi in reversed(sorted(b.keys())):
        f = largest_factor(bi)
        if bi > f > 1:
            while f in b and bi in b:
                b[f] -= 1
                b[bi] -= 1
                if not b[f]:
                    del b[f]
                if not b[bi]:
                    del b[bi]
                a.append(bi)

    for i, pi in enumerate(p):
        if p_inv[i]:
            while i in b and pi in b:
                b[i] -= 1
                b[pi] -= 1
                if not b[i]:
                    del b[i]
                if not b[pi]:
                    del b[pi]
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    input()
    b = [int(bi) for bi in input().split()]
    b.sort(reverse=True)

    counter = [0] * 2750132
    for bi in b:
        counter[bi] += 1

    primes = prime_list(2750131)
    is_prime = [False] * 2750132
    for pi in primes:
        is_prime[pi] = True

    a = []

    for bi in b:
        f = largest_factor(bi)
        if f:
            while counter[f] and counter[bi]:
                counter[f] -= 1
                counter[bi] -= 1
                a.append(bi)

    for i, pi in enumerate(primes):
        if is_prime[i]:
            while counter[i] and counter[pi]:
                counter[i] -= 1
                counter[pi] -= 1
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []

    for bi in list(b.elements()):
        f = all_factors(bi)
        if f:
            b[f] -= 1
            b[bi] -= 1
            if not b[f]:
                del b[f]
            if not b[bi]:
                del b[bi]
            a.append(bi)

    for i, pi in enumerate(p):
        while i in b and pi in b and p_inv[i]:
            b[i] -= 1
            b[pi] -= 1
            if not b[i]:
                del b[i]
            if not b[pi]:
                del b[pi]
            a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []

    for bi in list(b.elements()):
        f = largest_factor(bi)
        if f > 1:
            while f in b and bi in b:
                b[f] -= 1
                b[bi] -= 1
                if not b[f]:
                    del b[f]
                if not b[bi]:
                    del b[bi]
                a.append(bi)

    for i, pi in enumerate(p):
        if p_inv[i]:
            while i in b and pi in b:
                b[i] -= 1
                b[pi] -= 1
                if not b[i]:
                    del b[i]
                if not b[pi]:
                    del b[pi]
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    input()
    b = [int(bi) for bi in input().split()]

    counter = [0] * 2750132
    for bi in b:
        counter[bi] += 1

    primes = prime_list(2750131)
    is_prime = [False] * 2750132
    for pi in primes:
        is_prime[pi] = True

    a = []

    for bi in sorted(set(b), reverse=True):
        f = largest_factor(bi)
        if f:
            while counter[f] and counter[bi]:
                counter[f] -= 1
                counter[bi] -= 1
                a.append(bi)

    for i, pi in enumerate(primes):
        if is_prime[i]:
            while counter[i] and counter[pi]:
                counter[i] -= 1
                counter[pi] -= 1
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def largest_factor(n):
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []

    for bi in list(b.keys()):
        f = largest_factor(bi)
        if f > 1:
            while f in b and bi in b:
                b[f] -= 1
                b[bi] -= 1
                if not b[f]:
                    del b[f]
                if not b[bi]:
                    del b[bi]
                a.append(bi)

    for i, pi in enumerate(p):
        if p_inv[i]:
            while i in b and pi in b:
                b[i] -= 1
                b[pi] -= 1
                if not b[i]:
                    del b[i]
                if not b[pi]:
                    del b[pi]
                a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []
    for i, pi in enumerate(p):
        while i in b and pi in b and p_inv[i]:
            b[i] -= 1
            b[pi] -= 1
            if not b[i]:
                del b[i]
            if not b[pi]:
                del b[pi]
            a.append(i)

    for bi in list(b.elements()):
        f = all_factors(bi)
        if f:
            b[f] -= 1
            b[bi] -= 1
            if not b[f]:
                del b[f]
            if not b[bi]:
                del b[bi]
            a.append(bi)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []
    for i, pi in enumerate(p):
        if i in b and pi in b and p_inv[i]:
            b[i] -= 1
            b[pi] -= 1
            if not b[i]:
                del b[i]
            if not b[pi]:
                del b[pi]
            a.append(i)

    for bi in list(b.elements()):
        f = all_factors(bi)
        if f:
            b[f] -= 1
            b[bi] -= 1
            if not b[f]:
                del b[f]
            if not b[bi]:
                del b[bi]
            a.append(bi)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = [0]
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    for i in range(2, int(n**0.5) + 1):
        if not n % i:
            return n // i
    return 0

def main():
    n = int(input())
    b = Counter([int(bi) for bi in input().split()])
    p = prime_list(2750131)
    p_inv = [False] * 2750132
    for pi in p:
        p_inv[pi] = True

    a = []

    for bi in list(b.elements()):
        f = all_factors(bi)
        if f:
            while f in b and bi in b:
                b[f] -= 1
                b[bi] -= 1
                if not b[f]:
                    del b[f]
                if not b[bi]:
                    del b[bi]
                a.append(bi)

    for i, pi in enumerate(p):
        while i in b and pi in b and p_inv[i]:
            b[i] -= 1
            b[pi] -= 1
            if not b[i]:
                del b[i]
            if not b[pi]:
                del b[pi]
            a.append(i)

    print(*a)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat

# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def sieve_of_eratosthenes(n):
    primes = [True] * (n+1)
    p = 2
    while p * p <= n:
        if primes[p]:
            for i in range(p * 2, n + 1, p):
                primes[i] = False
        p += 1
    primes = [element for element in range(2, n) if primes[element]]
    re = {i:idx+1 for idx, i in enumerate(primes)}
    return re

def getm(n):
    p = 2
    while p*p<=n:
        if n%p == 0:
            return n/p
        p+=1
pr = sieve_of_eratosthenes(2750133)

n = map(int, raw_input().split())[0]
da = map(int, raw_input().split())
da.sort(reverse=True)
sda = defaultdict(int)
for i in da:
    sda[i] += 1
ans = []
for i in da:
    if not sda[i]:
        continue
    sda[i] -= 1
    if i in pr:
        ans.append(pr[i])
        sda[pr[i]] -= 1
    else:
        mf = getm(i)
        ans.append(i)
        sda[mf] -= 1
print ' '.join(map(str, ans))


import sys,math
from fractions import gcd
from bisect import bisect_left, bisect
from collections import defaultdict
from io import BytesIO
sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#4,8,15,16,23,42
#s = list(input())
#l = len(s)
arr = [int(_) for _ in input().split()]
def getm(n):
    i = 0
    while pr[i] <= n / 2:
        if n % pr[i] == 0:
            return n / pr[i]
        i += 1
    return 1
def primes():
    n = 2750133
    a = [0] * n
    for i in range(n):
        a[i] = i
    a[1] = 0

    m = 2
    while m < n:
        if a[m] != 0:
            j = m * 2
            while j < n:
                a[j] = 0
                j = j + m
        m += 1
    b = []
    for i in a:
        if a[i] != 0:
            b.append(a[i])

    del a
    return b
pr = primes()
s = set(pr)
mas = [0] * 2750133
for el in arr:
    mas[el] += 1
res = []
for i in range(len(mas)-1,0,-1):
    while mas[i] > 0:
        if i not in s:
            res.append(i)
            x = getm(i)
            mas[x] -= 1
            mas[i] -= 1
        else:
            break
#print(mas[:10],res)
for i in range(len(mas)):
    while mas[i] > 0:
        #print(i)
        res.append(i)
        mas[pr[i-1]] -= 1
        mas[i] -= 1
#print(mas[:10],res)
print(' '.join([str(x) for x in res]))


import sys,math
from fractions import gcd
from bisect import bisect_left, bisect
from collections import defaultdict
from io import BytesIO
sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#4,8,15,16,23,42
#s = list(input())
#l = len(s)
arr = [int(_) for _ in input().split()]
def getm(n):
    i = 0
    while pr[i] < n / 2:
        if n % pr[i] == 0:
            return n / pr[i]
        i += 1
    return 1
def primes():
    n = 2750133
    a = [0] * n
    for i in range(n):
        a[i] = i
    a[1] = 0

    m = 2
    while m < n:
        if a[m] != 0:
            j = m * 2
            while j < n:
                a[j] = 0
                j = j + m
        m += 1
    b = []
    for i in a:
        if a[i] != 0:
            b.append(a[i])

    del a
    return b
pr = primes()
s = set(pr)
mas = [0] * 2750133
for el in arr:
    mas[el] += 1
res = []
for i in range(len(mas)-1,0,-1):
    while mas[i] > 0:
        if i not in s:
            res.append(i)
            x = getm(i)
            mas[x] -= 1
            mas[i] -= 1
        else:
            break
#print(mas[:10],res)
for i in range(len(mas)):
    while mas[i] > 0:
        #print(i)
        res.append(i)
        mas[pr[i-1]] -= 1
        mas[i] -= 1
#print(mas[:10],res)
print(' '.join([str(x) for x in res]))


import sys,math
from fractions import gcd
from bisect import bisect_left, bisect
from collections import defaultdict
from io import BytesIO
sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#4,8,15,16,23,42
#s = list(input())
#l = len(s)
arr = [int(_) for _ in input().split()]
def getm(n):
    x = n / 2
    while n % x > 0:
        x -= 1
    return x
def primes():
    n = 2750133
    a = [0] * n
    for i in range(n):
        a[i] = i
    a[1] = 0

    m = 2
    while m < n:
        if a[m] != 0:
            j = m * 2
            while j < n:
                a[j] = 0
                j = j + m
        m += 1
    b = []
    for i in a:
        if a[i] != 0:
            b.append(a[i])

    del a
    return b
pr = primes()
s = set(pr)
mas = [0] * 2750133
for el in arr:
    mas[el] += 1
res = []
for i in range(len(mas)-1,0,-1):
    while mas[i] > 0:
        if i not in s:
            res.append(i)
            x = getm(i)
            mas[x] -= 1
            mas[i] -= 1
        else:
            break
#print(mas[:10],res)
for i in range(len(mas)):
    while mas[i] > 0:
        #print(i)
        res.append(i)
        mas[pr[i-1]] -= 1
        mas[i] -= 1
#print(mas[:10],res)
print(' '.join([str(x) for x in res]))


from collections import Counter
from sys import stdin, stdout
raw_input = stdin.readline
pr = stdout.write
sv=[i for i in xrange(3000005)]
cnt=1
d=Counter()
for i in xrange(2,3000001):
    if i==sv[i]:
        d[i]=cnt
        cnt+=1
    else:
        sv[i]=i/sv[i]
        continue
    for j in xrange(i,3000001,i):
        sv[j]=min(sv[j],i)

n=input()
l=map(int,raw_input().split())
l.sort()
ans=[]
vis=Counter(l)
while l:
    x=l.pop()
    if not vis[x]>0:
        continue
    vis[x]-=1
    x1=x
    #print x,
    if sv[x]==x:
        x=d[x]
        ans.append(x)
    else:
        x=sv[x]
        ans.append(x1)
    vis[x]-=1
    #print x,vis

    #ans.append(x)
for i in ans:
    pr(str(i)+' ')
print


from collections import Counter
from sys import stdin, stdout
raw_input = stdin.readline
pr = stdout.write
sv=[i for i in xrange(3000005)]
cnt=1
d=Counter()
for i in xrange(2,3000001):
    if i==sv[i]:
        d[i]=cnt
        cnt+=1
    else:
        sv[i]=i/sv[i]
        continue
    for j in xrange(i,3000001,i):
        sv[j]=min(sv[j],i)

n=input()
l=map(int,raw_input().split())
l.sort()
ans=[]
vis=Counter(l)
while l:
    x=l.pop()
    if not vis[x]>0:
        continue
    vis[x]-=1
    #print x,
    if sv[x]==x:
        x=d[x]
    else:
        x=sv[x]

    vis[x]-=1
    #print x,vis

    ans.append(x)
for i in ans:
    pr(str(i)+' ')


"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival"
from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    prime = [True for i in range(3*(10**6)+1)]
    def SieveOfEratosthenes(n):

        p = 2
        while (p * p <= n):
            if (prime[p] == True):
                for i in range(p * p, n+1, p):
                    prime[i] = False
            p += 1
        x=[]
        for p in range(2,n):
            if prime[p]:
                x.append(p)
        return x
    primelist=SieveOfEratosthenes(3*(10**6))
    n=int(input())
    b=list(map(int,input().split()))
    b.sort()
    b=b[::-1]
    a=[]
    d1={}
    for item in b:
        if item in d1:
            d1[item]+=1
        else :
            d1[item]=1
    import bisect
    for item in b:
        if item not in d1:
            continue
        d1[item]-=1
        if d1[item]==0:
            del d1[item]
        if prime[item]:
            x=bisect.bisect_right(primelist,item)
            d1[x]-=1
            if d1[x]==0:
                del d1[x]
            a.append(x)
        else :
            a.append(item)
            for i in range(2,int(item**0.5)+1):
                if item%i==0:
                    j=i
                    break

            d1[item//j]-=1
            if d1[item//j]==0:
                del d1[item//j]
    print(' '.join(str(x) for x in a))

if __name__ == '__main__':
    sync_with_stdio(False)
    main()


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, n):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i] == i:
            yield i
        if i + 2 <= n and prim[i + 2] == i + 2:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = sorted(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and prim[a[i]] != a[i]:
        g = a[i] // lowest_prime(a[i])
        ans.append(a[i])
        mem2[a[i]] -= 1
        mem2[g] -= 1

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and len(ans) < n and len(primes) > a[i] - 1 and mem2[primes[a[i] - 1]]:
        ans.append(a[i])
        mem2[a[i]] -= 1
        mem2[primes[a[i] - 1]] -= 1

print(' '.join(map(str, ans)))


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, int(n ** .5) + 1):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i] == i:
            yield i
        if i + 2 <= n and prim[i + 2] == i + 2:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = sorted(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and prim[a[i]] != a[i]:
        g = a[i] // lowest_prime(a[i])
        ans.append(a[i])
        mem2[a[i]] -= 1
        mem2[g] -= 1

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and len(ans) < n and len(primes) > a[i] - 1 and mem2[primes[a[i] - 1]]:
        ans.append(a[i])
        mem2[a[i]] -= 1
        mem2[primes[a[i] - 1]] -= 1

print(' '.join(map(str, ans)))


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, n):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i]:
            yield i
        if i + 2 <= n and prim[i + 2]:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = sorted(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]]:
        if prim[a[i]] != a[i]:
            g = a[i] // lowest_prime(a[i])
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[g] -= 1

# print(mem2, ans)
for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and len(ans) < n:
        if mem2[primes[a[i] - 1]]:
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[primes[a[i] - 1]] -= 1

print(' '.join(map(str, ans)))


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, n):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i]:
            yield i
        if i + 2 <= n and prim[i + 2]:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = set(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]]:
        if a[i] not in primes:
            g = a[i] // lowest_prime(a[i])
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[g] -= 1

# print(mem2, ans)
for i in range(n * 2):
    if mem2[a[i]] and len(ans) < n:
        ans.append(a[i])
        mem2[a[i]] -= 1

print(' '.join(map(str, ans)))


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, n):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i]:
            yield i
        if i + 2 <= n and prim[i + 2]:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = set(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2):
    if mem2[a[i]]:
        if a[i] not in primes:
            g = a[i] // lowest_prime(a[i])
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[g] -= 1

# print(mem2, ans)
for i in range(n * 2):
    if mem2[a[i]] and len(ans) < n:
        ans.append(a[i])
        mem2[a[i]] -= 1

print(' '.join(map(str, ans)))


from sys import stdin
from collections import *

def count_prime(n):
    for i in range(2, n):
        if not prim[i]:
            for j in range(i, n, i):
                prim[j] = i

    for i in range(1, n):
        if not prim[i]:
            prim[i] = i

    yield 2
    yield 3
    for i in range(5, n, 6):
        if prim[i] == i:
            yield i
        if i + 2 <= n and prim[i + 2] == i + 2:
            yield i + 2

def lowest_prime(x):
    if mem[x]:
        return mem[x]

    for i in primes:
        if i * i > x:
            mem[x] = x
            return x
        elif x % i == 0:
            mem[x] = i
            return i

rints = lambda: [int(x) for x in stdin.readline().split()]
N, Max = 2750132, 2 * 10 ** 5 + 1

n, a = int(input()), sorted(rints())
prim, mem = [0] * N, [0] * Max
primes, ans = sorted(count_prime(N)), []
mem2 = Counter(a)

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]]:
        if prim[a[i]] != a[i]:
            g = a[i] // lowest_prime(a[i])
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[g] -= 1

for i in range(n * 2 - 1, -1, -1):
    if mem2[a[i]] and len(ans) < n:
        if len(primes) > a[i] - 1 and mem2[primes[a[i] - 1]]:
            ans.append(a[i])
            mem2[a[i]] -= 1
            mem2[primes[a[i] - 1]] -= 1

print(' '.join(map(str, ans)))


import itertools as it

def erat2a( ):
    D = {  }
    yield 2
    for q in it.islice(it.count(3), 0, None, 2):
        p = D.pop(q, None)
        if p is None:
            D[q*q] = q
            yield q
        else:
            x = q + 2*p
            while x in D:
                x += 2*p
            D[x] = p

def prime_map(n):
	pm = {}
	g = erat2a()
	for i in range(n):
		pm[g.next()] = i + 1
	return pm

# Main solver function
def recover_it(data):
	a = list()
	n = 199999
	pm = prime_map(n)

	data.sort(reverse=True)
	while len(data) > 0:
		i = data.pop(0)
		if pm.has_key(i):
			index = data.index(pm[i])
			ai = data.pop(index)
			a.append(ai)
		else:
			for j in data:
				if i % j == 0 and i != j:
					data.pop(data.index(j))
					a.append(i)
					break

	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


#!/usr/bin/python

def recover_it(data):
	a = list()
	p = list()

	data.sort(reverse=True)
	while len(data) > 1:
		i = data.pop(0)
		sz = len(data)
		for j in data:
			if i % j == 0 and i != j:
				data.pop(data.index(j))
				break

		if len(data) != sz:
			a.append(i)
		else:
			p.append(i)

	p += data
	p.sort()
	l = (len(p) / 2)

	a = a + p[0:l]
	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


def recover_it(data):
	a = list()
	p = list()

	data.sort(reverse=True)
	while len(data) > 1:
		i = data.pop(0)
		sz = len(data)
		for j in data:
			if i % j == 0 and i != j:
				data.pop(data.index(j))
				break

		if len(data) != sz:
			a.append(i)
		else:
			p.append(i)

	p += data
	p.sort()
	l = (len(p) / 2)

	a = a + p[0:l]
	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


#!/usr/bin/python

def prime_generator():
    D = {}
    q = 2
    while True:
        if q not in D:
            yield q
            D[q * q] = [q]
        else:
            for p in D[q]:
                D.setdefault(p + q, []).append(p)
            del D[q]
        q += 1

def prime_map(n):
	pm = {}
	g = prime_generator()
	for i in range(n):
		pm[g.next()] = i + 1
	return pm

# Main solver function
def recover_it(data):
	a = list()
	n = min(max(data), 199999)
	pm = prime_map(n)

	data.sort(reverse=True)
	while len(data) > 0:
		i = data.pop(0)
		if pm.has_key(i):
			index = data.index(pm[i])
			ai = data.pop(index)
			a.append(ai)
		else:
			for j in data:
				if i % j == 0 and i != j:
					data.pop(data.index(j))
					a.append(i)
					break

	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


#!/usr/bin/python

def prime_generator():
    D = {}
    q = 2
    while True:
        if q not in D:
            yield q
            D[q * q] = [q]
        else:
            for p in D[q]:
                D.setdefault(p + q, []).append(p)
            del D[q]
        q += 1

def prime_map(n):
	pm = {}
	g = prime_generator()
	for i in range(n):
		pm[i+1] = g.next()
	return pm

# Main solver function
def recover_it(data):
	a = list()
	p = list()

	data.sort(reverse=True)
	while len(data) > 1:
		i = data.pop(0)
		sz = len(data)
		for j in data:
			if i % j == 0 and i != j:
				data.pop(data.index(j))
				break

		if len(data) != sz:
			a.append(i)
		else:
			p.append(i)

	p += data
	p.sort()

	l = len(p) / 2
	pm = prime_map(199999)
	for i in range(l):
		j = p.pop(0)
		index = p.index(pm[j])
		p.pop(index)
		a.append(j)

	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


#!/usr/bin/python

N = 3 * 1000 * 1000 + 13

def sieve(lst, num):
	for i in range(N):
		lst[i] = i

	for i in range(2, N):
		if lst[i] != i:
			lst[i] = i / lst[i]
			continue

		j = pow(i, 2)
		while j < N:
			lst[j] = min(lst[j], i)
			j += i

	cur = 1
	for i in range(2, N):
		if lst[i] == i:
			num[i] = cur
			cur += 1

	return lst, num

# Main solver function
def recover_it(n, data):
	lst0 = [0 for i in range(N)]
	num0 = [0 for i in range(N)]
	lst, num = sieve(lst0, num0)

	cnt = [0 for x in range(N)]
	res = list()
	for i in data:
		cnt[i] += 1

	for i in range(N - 1, 0, -1):
		while cnt[i] > 0:
			if lst[i] == i:
				cnt[num[i]] -= 1
				res.append(num[i])
			else:
				cnt[lst[i]] -= 1
				res.append(i)
			cnt[i] -= 1

	a_str = [str(x) for x in res]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]
solution = " ".join(recover_it(n, data))
print solution


#!/usr/bin/python

def prime_generator():
    D = {}
    q = 2
    while True:
        if q not in D:
            yield q
            D[q * q] = [q]
        else:
            for p in D[q]:
                D.setdefault(p + q, []).append(p)
            del D[q]
        q += 1

def prime_map(n):
	pm = {}
	g = prime_generator()
	for i in range(n):
		pm[g.next()] = i + 1
	return pm

# Main solver function
def recover_it(data):
	a = list()
	pm = prime_map(199999)

	data.sort(reverse=True)
	while len(data) > 0:
		i = data.pop(0)
		if pm.has_key(i):
			index = data.index(pm[i])
			ai = data.pop(index)
			a.append(ai)
		else:
			for j in data:
				if i % j == 0 and i != j:
					data.pop(data.index(j))
					a.append(i)
					break

	a_str = [str(x) for x in a]
	return a_str

# Main
n = int(raw_input())
raw_data = raw_input().split(" ")
data = [int(x) for x in raw_data]

solution = " ".join(recover_it(data))
print solution


def main():
    big = 2750131 + 10
    P = [1]*big
    P[0] = P[1] = 0
    smallest = [0]*big
    for i in range(big):
        if P[i]:
            j = i + i
            while j<big:
                if P[j]:
                    P[j] = 0
                    smallest[j] = i
                j += i

    cumsum = [0]
    for p in P:
        cumsum.append(cumsum[-1] + p)
    cumsum.pop(0)

    inp = readnumbers()
    ii = 0

    n = inp[ii]
    ii += 1
    mset = TreapMultiSet(inp[ii:])

    A = []
    for i in range(n):
        top = mset.max()
        mset.remove(top)
        if P[top]:
            back = cumsum[top]
            mset.remove(back)
            A.append(back)
        else:
            back = top//smallest[top]
            mset.remove(back)
            A.append(top)
    print ' '.join(str(x) for x in A)

        #if P[top]:

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

import random

class TreapMultiSet(object):
    root = 0
    size = 0

    def __init__(self, data=None):
        if data:
            data = sorted(data)
            self.root = treap_builder(data)
            self.size = len(data)

    def add(self, key):
        self.root = treap_insert(self.root, key)
        self.size += 1

    def remove(self, key):
        self.root = treap_erase(self.root, key)
        self.size -= 1

    def discard(self, key):
        try:
            self.remove(key)
        except KeyError:
            pass

    def ceiling(self, key):
        x = treap_ceiling(self.root, key)
        return treap_keys[x] if x else None

    def higher(self, key):
        x = treap_higher(self.root, key)
        return treap_keys[x] if x else None

    def floor(self, key):
        x = treap_floor(self.root, key)
        return treap_keys[x] if x else None

    def lower(self, key):
        x = treap_lower(self.root, key)
        return treap_keys[x] if x else None

    def max(self):
        return treap_keys[treap_max(self.root)]

    def min(self):
        return treap_keys[treap_min(self.root)]

    def __len__(self):
        return self.size

    def __nonzero__(self):
        return bool(self.root)

    __bool__ = __nonzero__

    def __contains__(self, key):
        return self.floor(key) == key

    def __repr__(self):
        return 'TreapMultiSet([%s])' % ', '.join(str(key) for key in self)

    def __iter__(self):
        if not self.root:
            return iter([])
        out = []
        stack = [self.root]
        while stack:
            node = stack.pop()
            if node > 0:
                if right_child[node]:
                    stack.append(right_child[node])
                stack.append(~node)
                if left_child[node]:
                    stack.append(left_child[node])
            else:
                out.append(treap_keys[~node])
        return iter(out)

class TreapSet(TreapMultiSet):
    def add(self, key):
        self.root, duplicate = treap_insert_unique(self.root, key)
        if not duplicate:
            self.size += 1

    def __repr__(self):
        return 'TreapSet([%s])' % ', '.join(str(key) for key in self)

class TreapHashSet(TreapMultiSet):
    def __init__(self, data=None):
        if data:
            self.keys = set(data)
            super(TreapHashSet, self).__init__(self.keys)
        else:
            self.keys = set()

    def add(self, key):
        if key not in self.keys:
            self.keys.add(key)
            super(TreapHashSet, self).add(key)

    def remove(self, key):
        self.keys.remove(key)
        super(TreapHashSet, self).remove(key)

    def discard(self, key):
        if key in self.keys:
            self.remove(key)

    def __contains__(self, key):
        return key in self.keys

    def __repr__(self):
        return 'TreapHashSet([%s])' % ', '.join(str(key) for key in self)

class TreapHashMap(TreapMultiSet):
    def __init__(self, data=None):
        if data:
            self.map = dict(data)
            super(TreapHashMap, self).__init__(self.map.keys())
        else:
            self.map = dict()

    def __setitem__(self, key, value):
        if key not in self.map:
            super(TreapHashMap, self).add(key)
        self.map[key] = value

    def __getitem__(self, key):
        return self.map[key]

    def add(self, key):
        raise TypeError("add on TreapHashMap")

    def get(self, key, default=None):
        return self.map.get(key, default=default)

    def remove(self, key):
        self.map.pop(key)
        super(TreapHashMap, self).remove(key)

    def discard(self, key):
        if key in self.map:
            self.remove(key)

    def __contains__(self, key):
        return key in self.map

    def __repr__(self):
        return 'TreapHashMap([%s])' % ', '.join('(%s, %s)' % (str(key), str(self.map[key])) for key in self)

# Build a treap in O(n) time using sorted data
def treap_builder(sorted_data):
    def build(begin, end):
        if begin == end:
            return 0
        mid = (begin + end) // 2
        root = treap_create_node(sorted_data[mid])
        left_child[root] = build(begin, mid)
        right_child[root] = build(mid + 1, end)

        # sift down the priorities
        ind = root
        while True:
            lc = left_child[ind]
            rc = right_child[ind]

            if lc and treap_prior[lc] > treap_prior[ind]:
                if rc and treap_prior[rc] > treap_prior[rc]:
                    treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                    ind = rc
                else:
                    treap_prior[ind], treap_prior[lc] = treap_prior[lc], treap_prior[ind]
                    ind = lc
            elif rc and treap_prior[rc] > treap_prior[ind]:
                treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                ind = rc
            else:
                break
        return root

    return build(0, len(sorted_data))

left_child = [0]
right_child = [0]
treap_keys = [0]
treap_prior = [0.0]

def treap_create_node(key):
    treap_keys.append(key)
    treap_prior.append(random.random())
    left_child.append(0)
    right_child.append(0)
    return len(treap_keys) - 1

def treap_split(root, key):
    left_pos = right_pos = 0
    while root:
        if key < treap_keys[root]:
            left_child[right_pos] = right_pos = root
            root = left_child[root]
        else:
            right_child[left_pos] = left_pos = root
            root = right_child[root]
    left, right = right_child[0], left_child[0]
    right_child[left_pos] = left_child[right_pos] = right_child[0] = left_child[0] = 0
    return left, right

def treap_merge(left, right):
    where, pos = left_child, 0
    while left and right:
        if treap_prior[left] > treap_prior[right]:
            where[pos] = pos = left
            where = right_child
            left = right_child[left]
        else:
            where[pos] = pos = right
            where = left_child
            right = left_child[right]
    where[pos] = left or right
    node = left_child[0]
    left_child[0] = 0
    return node

def treap_insert(root, key):
    if not root:
        return treap_create_node(key)
    left, right = treap_split(root, key)
    return treap_merge(treap_merge(left, treap_create_node(key)), right)

def treap_insert_unique(root, key):
    if not root:
        return treap_create_node(key), False
    left, right = treap_split(root, key)
    if left and treap_keys[left] == key:
        return treap_merge(left, right), True
    return treap_merge(treap_merge(left, treap_create_node(key)), right), False

def treap_erase(root, key):
    if not root:
        raise KeyError(key)
    if treap_keys[root] == key:
        return treap_merge(left_child[root], right_child[root])
    node = root
    while root and treap_keys[root] != key:
        parent = root
        root = left_child[root] if key < treap_keys[root] else right_child[root]
    if not root:
        raise KeyError(key)
    if root == left_child[parent]:
        left_child[parent] = treap_merge(left_child[root], right_child[root])
    else:
        right_child[parent] = treap_merge(left_child[root], right_child[root])

    return node

def treap_ceiling(root, key):
    while root and treap_keys[root] < key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] < key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_higher(root, key):
    while root and treap_keys[root] <= key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] <= key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_floor(root, key):
    while root and treap_keys[root] > key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] > key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_lower(root, key):
    while root and treap_keys[root] >= key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] >= key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_min(root):
    if not root:
        raise ValueError('min on empty treap')
    while left_child[root]:
        root = left_child[root]
    return root

def treap_max(root):
    if not root:
        raise ValueError('max on empty treap')
    while right_child[root]:
        root = right_child[root]
    return root

if __name__== "__main__":
  main()


def main():
    big = 2750131 + 10
    P = [1]*big
    P[0] = P[1] = 0
    smallest = [0]*big
    for i in range(min(int(big**0.5 + 10), big)):
        if P[i]:
            j = i + i
            while j<big:
                if P[j]:
                    P[j] = 0
                    smallest[j] = i
                j += i
    cumsum = [0]
    for p in P:
        cumsum.append(cumsum[-1] + p)
    cumsum.pop(0)

    inp = readnumbers()
    ii = 0

    n = inp[ii]
    ii += 1
    mset = TreapMultiSet(inp[ii:])

    A = []
    for i in range(n):
        top = mset.max()
        mset.remove(top)
        if P[top]:
            back = cumsum[top]
            mset.remove(back)
            A.append(back)
        else:
            back = top//smallest[top]
            mset.remove(back)
            A.append(top)
    print ' '.join(str(x) for x in A)

        #if P[top]:

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

import random

class TreapMultiSet(object):
    root = 0
    size = 0

    def __init__(self, data=None):
        if data:
            data = sorted(data)
            self.root = treap_builder(data)
            self.size = len(data)

    def add(self, key):
        self.root = treap_insert(self.root, key)
        self.size += 1

    def remove(self, key):
        self.root = treap_erase(self.root, key)
        self.size -= 1

    def discard(self, key):
        try:
            self.remove(key)
        except KeyError:
            pass

    def ceiling(self, key):
        x = treap_ceiling(self.root, key)
        return treap_keys[x] if x else None

    def higher(self, key):
        x = treap_higher(self.root, key)
        return treap_keys[x] if x else None

    def floor(self, key):
        x = treap_floor(self.root, key)
        return treap_keys[x] if x else None

    def lower(self, key):
        x = treap_lower(self.root, key)
        return treap_keys[x] if x else None

    def max(self):
        return treap_keys[treap_max(self.root)]

    def min(self):
        return treap_keys[treap_min(self.root)]

    def __len__(self):
        return self.size

    def __nonzero__(self):
        return bool(self.root)

    __bool__ = __nonzero__

    def __contains__(self, key):
        return self.floor(key) == key

    def __repr__(self):
        return 'TreapMultiSet([%s])' % ', '.join(str(key) for key in self)

    def __iter__(self):
        if not self.root:
            return iter([])
        out = []
        stack = [self.root]
        while stack:
            node = stack.pop()
            if node > 0:
                if right_child[node]:
                    stack.append(right_child[node])
                stack.append(~node)
                if left_child[node]:
                    stack.append(left_child[node])
            else:
                out.append(treap_keys[~node])
        return iter(out)

class TreapSet(TreapMultiSet):
    def add(self, key):
        self.root, duplicate = treap_insert_unique(self.root, key)
        if not duplicate:
            self.size += 1

    def __repr__(self):
        return 'TreapSet([%s])' % ', '.join(str(key) for key in self)

class TreapHashSet(TreapMultiSet):
    def __init__(self, data=None):
        if data:
            self.keys = set(data)
            super(TreapHashSet, self).__init__(self.keys)
        else:
            self.keys = set()

    def add(self, key):
        if key not in self.keys:
            self.keys.add(key)
            super(TreapHashSet, self).add(key)

    def remove(self, key):
        self.keys.remove(key)
        super(TreapHashSet, self).remove(key)

    def discard(self, key):
        if key in self.keys:
            self.remove(key)

    def __contains__(self, key):
        return key in self.keys

    def __repr__(self):
        return 'TreapHashSet([%s])' % ', '.join(str(key) for key in self)

class TreapHashMap(TreapMultiSet):
    def __init__(self, data=None):
        if data:
            self.map = dict(data)
            super(TreapHashMap, self).__init__(self.map.keys())
        else:
            self.map = dict()

    def __setitem__(self, key, value):
        if key not in self.map:
            super(TreapHashMap, self).add(key)
        self.map[key] = value

    def __getitem__(self, key):
        return self.map[key]

    def add(self, key):
        raise TypeError("add on TreapHashMap")

    def get(self, key, default=None):
        return self.map.get(key, default=default)

    def remove(self, key):
        self.map.pop(key)
        super(TreapHashMap, self).remove(key)

    def discard(self, key):
        if key in self.map:
            self.remove(key)

    def __contains__(self, key):
        return key in self.map

    def __repr__(self):
        return 'TreapHashMap([%s])' % ', '.join('(%s, %s)' % (str(key), str(self.map[key])) for key in self)

# Build a treap in O(n) time using sorted data
def treap_builder(sorted_data):
    def build(begin, end):
        if begin == end:
            return 0
        mid = (begin + end) // 2
        root = treap_create_node(sorted_data[mid])
        left_child[root] = build(begin, mid)
        right_child[root] = build(mid + 1, end)

        # sift down the priorities
        ind = root
        while True:
            lc = left_child[ind]
            rc = right_child[ind]

            if lc and treap_prior[lc] > treap_prior[ind]:
                if rc and treap_prior[rc] > treap_prior[rc]:
                    treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                    ind = rc
                else:
                    treap_prior[ind], treap_prior[lc] = treap_prior[lc], treap_prior[ind]
                    ind = lc
            elif rc and treap_prior[rc] > treap_prior[ind]:
                treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                ind = rc
            else:
                break
        return root

    return build(0, len(sorted_data))

left_child = [0]
right_child = [0]
treap_keys = [0]
treap_prior = [0.0]

def treap_create_node(key):
    treap_keys.append(key)
    treap_prior.append(random.random())
    left_child.append(0)
    right_child.append(0)
    return len(treap_keys) - 1

def treap_split(root, key):
    left_pos = right_pos = 0
    while root:
        if key < treap_keys[root]:
            left_child[right_pos] = right_pos = root
            root = left_child[root]
        else:
            right_child[left_pos] = left_pos = root
            root = right_child[root]
    left, right = right_child[0], left_child[0]
    right_child[left_pos] = left_child[right_pos] = right_child[0] = left_child[0] = 0
    return left, right

def treap_merge(left, right):
    where, pos = left_child, 0
    while left and right:
        if treap_prior[left] > treap_prior[right]:
            where[pos] = pos = left
            where = right_child
            left = right_child[left]
        else:
            where[pos] = pos = right
            where = left_child
            right = left_child[right]
    where[pos] = left or right
    node = left_child[0]
    left_child[0] = 0
    return node

def treap_insert(root, key):
    if not root:
        return treap_create_node(key)
    left, right = treap_split(root, key)
    return treap_merge(treap_merge(left, treap_create_node(key)), right)

def treap_insert_unique(root, key):
    if not root:
        return treap_create_node(key), False
    left, right = treap_split(root, key)
    if left and treap_keys[left] == key:
        return treap_merge(left, right), True
    return treap_merge(treap_merge(left, treap_create_node(key)), right), False

def treap_erase(root, key):
    if not root:
        raise KeyError(key)
    if treap_keys[root] == key:
        return treap_merge(left_child[root], right_child[root])
    node = root
    while root and treap_keys[root] != key:
        parent = root
        root = left_child[root] if key < treap_keys[root] else right_child[root]
    if not root:
        raise KeyError(key)
    if root == left_child[parent]:
        left_child[parent] = treap_merge(left_child[root], right_child[root])
    else:
        right_child[parent] = treap_merge(left_child[root], right_child[root])

    return node

def treap_ceiling(root, key):
    while root and treap_keys[root] < key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] < key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_higher(root, key):
    while root and treap_keys[root] <= key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] <= key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_floor(root, key):
    while root and treap_keys[root] > key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] > key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_lower(root, key):
    while root and treap_keys[root] >= key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] >= key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_min(root):
    if not root:
        raise ValueError('min on empty treap')
    while left_child[root]:
        root = left_child[root]
    return root

def treap_max(root):
    if not root:
        raise ValueError('max on empty treap')
    while right_child[root]:
        root = right_child[root]
    return root

if __name__== "__main__":
  main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def prime_sieve(n):
    """returns a sieve of primes >= 5 and < n"""
    flag = n % 6 == 2
    sieve = bytearray((n // 3 + flag >> 3) + 1)
    for i in range(1, int(n**0.5) // 3 + 1):
        if not (sieve[i >> 3] >> (i & 7)) & 1:
            k = (3 * i + 1) | 1
            for j in range(k * k // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
            for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
                sieve[j >> 3] |= 1 << (j & 7)
    return sieve

def prime_list(n):
    """returns a list of primes <= n"""
    res = []
    if n > 1:
        res.append(2)
    if n > 2:
        res.append(3)
    if n > 4:
        sieve = prime_sieve(n + 1)
        res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
    return res

from collections import defaultdict
def main():
    n = read_int()
    nums = read_int_array()
    nums.sort()
    primes = prime_list(2750131)
    prime_index = {x: i+1 for i, x in enumerate(primes)}
    out = []
    to_del = defaultdict(int)
    i = len(nums) - 1
    while i >= 0:
        x = nums[i]
        cnt = 1
        i -= 1
        while i >= 0 and nums[i] == x:
            cnt += 1
            i -= 1

        back = min(cnt, to_del.get(x, 0))
        cnt -= back
        to_del[x] -= back
        if not cnt:
            continue

        if x in prime_index:
            a = prime_index[x]
            out.extend([a]*cnt)
            to_del[a] += cnt
        else:
            out.extend([x]*cnt)
            for y in primes:
                if x % y == 0:
                    to_del[x // y] += cnt
                    break
    print(' '.join(str(x) for x in out))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

read = input
read_int = lambda: int(input())
read_array = lambda sep=None, maxsplit=-1: input().split(sep, maxsplit)
read_int_array = lambda: [int(a) for a in read_array()]

# endregion

if __name__ == "__main__":
    main()