Recently you have received two positive integer numbers $x$ and $y$. You forgot them, but you remembered a shuffled list containing all divisors of $x$ (including $1$ and $x$) and all divisors of $y$ (including $1$ and $y$). If $d$ is a divisor of both numbers $x$ and $y$ at the same time, there are two occurrences of $d$ in the list.

For example, if $x=4$ and $y=6$ then the given list can be any permutation of the list $[1, 2, 4, 1, 2, 3, 6]$. Some of the possible lists are: $[1, 1, 2, 4, 6, 3, 2]$, $[4, 6, 1, 1, 2, 3, 2]$ or $[1, 6, 3, 2, 4, 1, 2]$.

Your problem is to restore suitable positive integer numbers $x$ and $y$ that would yield the same list of divisors (possibly in different order).

It is guaranteed that the answer exists, i.e. the given list of divisors corresponds to some positive integers $x$ and $y$.


-----Input-----

The first line contains one integer $n$ ($2 \le n \le 128$) — the number of divisors of $x$ and $y$.

The second line of the input contains $n$ integers $d_1, d_2, \dots, d_n$ ($1 \le d_i \le 10^4$), where $d_i$ is either divisor of $x$ or divisor of $y$. If a number is divisor of both numbers $x$ and $y$ then there are two copies of this number in the list.


-----Output-----

Print two positive integer numbers $x$ and $y$ — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.


-----Example-----
Input
10
10 2 8 1 2 4 1 20 4 5

Output
20 8

Difficulty: EASY
Tags: Number theory

Complete search

Mathematics

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
arr = []
for i in a:
	if i != 1:
		arr.append(i)
if len(arr) == 0:
	print(1, 1)
	exit()
d = {}
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
both = []
for (key, value) in d.items():
	if value == 2:
		both.append(key)
a = sorted(a)
if len(a) == 2:
	print(a[0], a[1])
	exit()
if len(arr) == 1:
	print(a[0], a[-1])
	exit()
arr = sorted(arr)
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		f1 = True
		x = a[i]
		y = a[j]
		for k in range(len(both)):
			if x % both[k] != 0 or y % both[k] != 0:
				f1 = False
				break
		f2 = True
		for k in range(len(a)):
			if x % a[k] != 0 and y % a[k] != 0:
				f2 = False
				break
		if f1 and f2:
			print(x, y)
			exit()


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
a[n - 1] = -1
i = 0
while i < n - 1:
	ok = False
	j = 0
	if x % a[i] == 0 and a[i] != x:
		ok = True
		j = i
	if a[i + 1] == a[i]:
		i += 2
	else:
		i += 1
	if ok:
		a[j] = -1
for i in range(n - 1, -1, -1):
	if a[i] != -1:
		print(a[i], x)
		break


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
for i in range(1, int(x ** 0.5) + 1):
	if x % i == 0:
		if x // i == i:
			arr.remove(i)
		else:
			arr.remove(i)
			arr.remove(x // i)
print(x, max(arr))


import math
input()
data = [int(i) for i in input().split()]
a = max(data)
f = set()
q = set()
for num in data:
	if num in f:
		q.add(num)
	elif a % num == 0:
		f.add(num)
	else:
		q.add(num)
b = 1
for s in q:
	b = s * b // math.gcd(s, b)
print(a, b)


n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
del1 = a[0]
if a[0] == a[1]:
	del2 = a[1]
else:
	for i in range(1, n):
		if a[i] == a[i + 1]:
			del2 = a[i]
			break
		elif del1 % a[i] != 0:
			del2 = a[i]
			break
print(del1, del2)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
y = a[0]
count = {}
for i in a:
	count[i] = count.get(i, 0) + 1
for i in range(1, y + 1):
	if y % i == 0:
		if i in count:
			count[i] -= 1
			if count[i] == 0:
				del count[i]
second = []
for i in count:
	second.append(i)
x = max(second)
print(x, y)


n = int(input())
d = [int(i) for i in input().split()]
d = sorted(d)
y = max(d)
left = set()
took = set()
for i in d:
	if y % i == 0 and i in took:
		left.add(i)
	elif y % i == 0:
		took.add(i)
	else:
		left.add(i)
x = 1
for i in left:
	if i > x:
		x = i
print(x, y)


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(a[0], end=' ')
i = 1
while i < n:
	if a[i] == a[i - 1] or a[0] % a[i] != 0:
		print(a[i])
		i = n
	i += 1


def issame(data):
	if len(data) % 2 == 1:
		return 0
	data.sort()
	for i in range(0, int(len(data) / 2)):
		if data[2 * i] != data[2 * i + 1]:
			return 0
	return 1
n = int(input())
data = list(map(int, input().split()))
x = 1
y = 1
if issame(data) == 1:
	data.sort()
	x = data[-1]
	y = x
	print(x, y)
	exit()
data.sort()
y = data[-1]
i = 0
while len(data) > 0 and i < len(data):
	if y % data[i] == 0:
		j = i
		if i < len(data) - 1:
			if data[i + 1] != data[i]:
				i -= 1
		del data[j]
	i += 1
data.sort()
x = data[-1]
print(y, x)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
d_x = []
for (i, di) in enumerate(d):
	if x % di == 0 and di not in d_x:
		d_x.append(di)
		d[i] = -1
y = max(d)
print(x, y)


n = int(input())
l = list(map(int, input().split()))
x = max(l)
divisor = []
for i in range(1, x + 1):
	if x % i == 0:
		divisor.append(i)
for div in divisor:
	if div in l:
		l.remove(div)
print(x, max(l))


import time
import sys
from math import sqrt

def main():
	n = int(input())
	div = sorted(list(map(int, sys.stdin.readline().split())))
	x = div[-1]
	for i in range(1, x + 1):
		if x % i == 0:
			div.remove(i)
	print(x, div[-1])
start_time = time.time()
main()


def div(m):
	if m == 1:
		return [1]
	d = [1, m]
	for i in range(2, int(m ** 0.5) + 1):
		if m % i == 0:
			d.append(i)
			if i != m // i:
				d.append(m // i)
	return d
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
m = l[-1]
for i in div(m):
	l.remove(i)
print(l[-1], m)


n = int(input())
D = list(map(int, input().split()))
x = max(D)
for i in range(1, x + 1):
	if x % i == 0:
		D.remove(i)
y = max(D)
print(x, y)


import math
k = int(input())
a = list(map(int, input().split()))
b = max(a)
for i in range(1, math.floor(math.sqrt(b)) + 1):
	if b % i == 0 and b // i == i:
		a.remove(i)
	elif b % i == 0:
		a.remove(i)
		a.remove(b // i)
print(b, max(a))


from collections import *
input()
d = Counter(map(int, input().split()))
m = max(d)
print(m, max((k for k in d if m % k or d[k] > 1)))


n = int(input())
import math

def printDivisors(n):
	k = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				k.append(i)
			else:
				k.append(i)
				k.append(int(n // i))
	return list(set(k))
c = list(map(int, input().split()))
c = sorted(c)
k = c[-1]
l = printDivisors(c[-1])
c.reverse()
for i in range(1, len(c)):
	if sorted(printDivisors(c[i]) + l) == sorted(c):
		print(k, c[i])
		break


n = int(input())
a = list(map(int, input().split()))
b = max(a)
c = []
for i in range(1, b // 2 + 1):
	if b % i == 0:
		c.append(i)
del a[a.index(b)]
for i in range(len(c)):
	del a[a.index(c[i])]
print(b, max(a))


n = int(input())
d = input().split(' ')
d = map(int, d)
d = list(d)
d = sorted(d)
if d[n - 1] == d[n - 2]:
	print(d[-1], d[-1])
else:
	dSet = list(set(d))
	x = max(d)
	dy = []
	for i in range(len(d) - 1):
		atual = d[i]
		prox = d[i + 1]
		if prox == atual:
			dy.append(atual)
	for i in dy:
		dSet.remove(i)
	dSet.remove(x)
	i = len(dSet) - 1
	while i >= 0:
		if x % dSet[i] == 0:
			dSet.remove(dSet[i])
		else:
			dy.append(dSet[i])
		i -= 1
	y = max(dy)
	print(x, y)


n = int(input())
a = list(map(int, input().split()))
x = max(a)
i = 1
r = int(x ** 0.5)
while i <= r:
	if x % i == 0:
		k = x // i
		a.remove(i)
		if i != k:
			a.remove(k)
	i += 1
y = max(a)
print(x, y)


input()
b = list(map(int, input().split()))
z = max(b)
for i in range(1, int(z ** 0.5) + 1):
	if i * i == z:
		b.remove(i)
		continue
	if z % i == 0:
		b.remove(i)
		b.remove(z // i)
print(z, max(b))


def factors(n):
	fact = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			if n // i == i:
				fact.append(i)
			else:
				fact.append(i)
				fact.append(n // i)
	fact.sort()
	return fact
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = arr[-1]
fact = factors(a)
(i, j) = (len(fact) - 2, n - 2)
while i >= 0 and j >= 0 and (fact[i] == arr[j]):
	i -= 1
	j -= 1
if i == -1:
	j = 0
print(*(a, arr[j]))


n = int(input())
l = list(map(int, input().strip().split()))
a = max(l)
visited = []
rr = []
for i in l:
	if a % i == 0 and i not in visited:
		visited.append(i)
	else:
		rr.append(i)
b = max(rr)
print(a, b)


n = int(input())
l = list(map(int, input().split()))

def solve():
	for i in range(VMAX, 0, -1):
		if cnt[i] == 2 or (cnt[i] == 1 and max_val % i != 0):
			return i
VMAX = 10 ** 4
cnt = [0] * (VMAX + 1)
max_val = l[0]
for val in l:
	max_val = max(max_val, val)
	cnt[val] += 1
print(max_val, solve())


from math import sqrt

def fac(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return sorted(l)
n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l[-1]
fx = fac(x)
for i in fx:
	l.remove(i)
l.sort()
y = l[-1]
print(x, y)


n = int(input())
lst = [int(j) for j in input().split(' ') if j != '' and j != ' ']
lst.sort()
num1 = lst[-1]
print(num1, end=' ')
i = 1
while i <= num1:
	if num1 % i == 0:
		lst.remove(i)
	i += 1
print(lst[-1])


d = int(input())
arr = list(map(int, input().split()))
m = max(arr)
for i in range(1, m + 1):
	if m % i == 0:
		for j in range(len(arr)):
			if arr[j] == i:
				del arr[j]
				break
print(m, max(arr))


import math
n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
for i in range(1, x + 1):
	if x % i == 0:
		arr.remove(i)
y = max(arr)
print(x, y)


n = int(input())
x = [int(i) for i in input().split()]
x.sort(reverse=True)
high = x[0]
for i in range(n):
	if high % x[i] != 0 or (high % x[i] == 0 and x[i] == x[i + 1]):
		print(f'{high} {x[i]}')
		break


from collections import defaultdict

def divisor(n):
	div = []
	p = n ** 0.5
	p = int(p)
	for i in range(1, p + 1):
		if n % i == 0:
			if n % i == i:
				div.append(i)
			else:
				div.append(i)
				div.append(n // i)
	return div
n = int(input())
arr = list(map(int, input().split()))
mx = max(arr)
freq = defaultdict(int)
for i in arr:
	freq[i] += 1
cnt = 0
for i in arr:
	if i == mx:
		cnt += 1
if cnt == 2:
	print(mx, mx)
else:
	div = divisor(mx)
	for i in div:
		if freq[i] == 1:
			if i in arr:
				x = arr.index(i)
				del arr[x]
	print(mx, max(arr))


q = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
x = a[-1]
for i in a[::-1]:
	if x % i != 0 or a.count(i) > 1:
		y = i
		break
print(x, y)


import math

def getDivisors(n):
	i = 1
	arr = []
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n / i)
		i = i + 1
	return arr
n = int(input())
arr = list(map(int, input().split()))
maxx = max(arr)
arr1 = getDivisors(maxx)
d = {}
for i in arr:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
for i in arr1:
	if d[i] == 1:
		del d[i]
	else:
		d[i] = 1
maxx1 = max(list(d.keys()))
print(maxx, maxx1)


def gcd(a: int, b: int):
	while b:
		(a, b) = (b, a % b)
	return a
n = int(input())
d = sorted(list(map(int, input().split())))
s = set()
(a, b) = (1, 1)
for i in d:
	if i in s:
		(a, b) = (a * (i // gcd(a, i)), b * (i // gcd(b, i)))
		s.remove(i)
	else:
		s.add(i)
for i in s:
	if a * (i // gcd(a, i)) in s:
		a *= i // gcd(a, i)
	else:
		b *= i // gcd(b, i)
print(a, b)


n = int(input())
d = list(map(int, input().split()))
m = max(d)
print(m, max((k for k in d if m % k or d.count(k) > 1)))


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
a = a[::-1]
m = a[0]
i = 0
while True:
	if a[i] == a[i + 1]:
		n = a[i]
		break
	elif m % a[i] != 0:
		n = a[i]
		break
	else:
		i += 1
		continue
print(m, n)


import os
import sys
from io import BytesIO, IOBase
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import gcd

def main():
	n = N()
	arr = RLL()
	arr.sort()
	a = arr[-1]
	for i in range(n - 1, -1, -1):
		if a % arr[i] != 0 and i != n - 1:
			print(a, arr[i])
			break
		elif arr[i] == arr[i - 1]:
			print(a, arr[i])
			break
main()


n = int(input())
l = sorted(list(map(int, input().split())))
num1 = l[-1]
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
num2 = 0
for i in l:
	if num1 % i != 0 or d[i] != 1:
		num2 = i
print(num1, num2)


n = int(input())
lis = list(map(int, input().split()))
f = max(lis)
f_lis = []
s_lis = []
for i in lis:
	if i not in f_lis and f % i == 0:
		f_lis.append(i)
	else:
		s_lis.append(i)
print(f, max(s_lis))


n = int(input())
lst = list(map(int, input().split()))
num1 = max(lst)
div = []
for i in lst:
	if num1 % i == 0:
		if i in div:
			num = 0
		else:
			div.append(i)
for i in div:
	lst.remove(i)
num2 = max(lst)
print(num1, num2)


def existsValueInList(arr, value):
	exist = False
	for val in arr:
		if val == value:
			exist = True
	return exist
n = int(input())
arr_divisors_str = input().split(' ')
arr_divisors_int = [int(i) for i in arr_divisors_str]
tmp_max = 0
arr_set = []
i = 0
while i < n:
	arr_set.append(arr_divisors_int[i])
	tmp_max = max(tmp_max, arr_divisors_int[i])
	i += 1
i = 1
while i <= tmp_max:
	if tmp_max % i == 0:
		if existsValueInList(arr_set, i):
			arr_set.remove(i)
	i += 1
arr_set.sort()
print(str(tmp_max) + ' ' + str(arr_set[len(arr_set) - 1]))


from collections import Counter

def mi():
	return map(int, input().split(' '))
n = int(input())
li = list(mi())
li.sort()
a = li[-1]
if li[-2] == a:
	print(a, a)
	exit()
b = -1
for i in li:
	if a % i != 0:
		b = max(b, i)
	elif li.count(i) == 2:
		b = max(b, i)
print(a, b)


from math import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
n = int(input())
a = list(map(int, input().split()))
m = max(a)
b = []
for i in a:
	if a.count(i) == 2:
		b.append(i)
		continue
	if m % i != 0:
		b.append(i)
if len(b) > 0:
	res = lcm(1, b[0])
	for i in b:
		res = lcm(res, i)
	print(m, res)
else:
	print(m, m * 2)


n = input()
nums = list(map(int, input().split()))
use = set()
M = max(nums)
N = 0
for d in nums:
	if d in use or M % d != 0:
		N = max(N, d)
	else:
		use.add(d)
print(M, N)


n = int(input())
d = [int(x) for x in input().split(' ')]
n1 = max(d)
d.remove(n1)
for x in range(1, n1):
	if n1 % x == 0:
		d.remove(x)
n2 = max(d)
print(n1, n2)


a = input()
b = list(map(int, input().split()))
b = [i for i in b]
x = max(b)
for i in range(1, x + 1):
	if x % i == 0:
		b.remove(i)
print(x, max(b))


import math
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
y = max(l)
for i in range(1, int(math.sqrt(y)) + 1):
	if y % i == 0:
		a1 = i
		a2 = y / i
		if a1 == a2:
			l.remove(a1)
		else:
			l.remove(a1)
			l.remove(a2)
x = max(l)
print(x, y, sep=' ')


n = int(input())
x = sorted(list(map(int, input().split())))
for i in range(2, n + 1):
	if x[-1] % x[-i] != 0 and x.count(x[-i]) == 1 or (x[-1] % x[-i] == 0 and x.count(x[-i]) == 2):
		print(x[-i], x[-1])
		break


def main():
	n = int(input())
	divisors = list(map(int, input().split()))
	divs = []
	div_dict = {}
	for i in divisors:
		if i not in div_dict.keys():
			div_dict[i] = 1
		else:
			div_dict[i] += 1
	divisors.sort(reverse=True)
	first = divisors[0]
	count1 = 0
	new = []
	prev = []
	t = False
	for i in divisors:
		if first % i == 0:
			if i not in prev:
				count1 += 1
				prev.append(i)
			else:
				new.append(i)
		else:
			new.append(i)
	for j in range(len(new)):
		count2 = 0
		curr = new[j]
		for i in new:
			if curr % i == 0:
				count2 += 1
		if count1 + count2 == n:
			second = curr
			break
	print(first, second)
main()


def main():

	def cmp_to_key(mycmp):

		class K(object):

			def __init__(self, obj, *args):
				self.obj = obj

			def __lt__(self, other):
				return mycmp(self.obj, other.obj) < 0

			def __gt__(self, other):
				return mycmp(self.obj, other.obj) > 0

			def __eq__(self, other):
				return mycmp(self.obj, other.obj) == 0

			def __le__(self, other):
				return mycmp(self.obj, other.obj) <= 0

			def __ge__(self, other):
				return mycmp(self.obj, other.obj) >= 0

			def __ne__(self, other):
				return mycmp(self.obj, other.obj) != 0
		return K
	n = int(input())
	q = list(map(int, input().split()))
	(m, res) = (max(q), -1000000000.0)
	for i in range(n):
		if m % q[i] or q.count(q[i]) > 1:
			res = max(q[i], res)
	print(m, res)
for qwerty in range(1):
	main()


def Read():
	n = int(input())
	arr = list(map(int, input().split()))
	return (n, arr)
(n, arr) = Read()
arr.sort()
num1 = arr[-1]
num2 = None
for i in range(len(arr) - 1, -1, -1):
	if num1 % arr[i] != 0:
		num2 = arr[i]
		break
	elif num1 % arr[i] == 0 and arr[i - 1] == arr[i]:
		num2 = arr[i]
		break
print(num1, num2)


n = int(input())
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
b = []
for i in a:
	s = a.count(i)
	if s == 2 and i not in b:
		b.append(i)
a = sorted(a)
a.reverse()
max1 = max(a)
a = a[1:]
a = list(set(a))
a = sorted(a)
a.reverse()
c = []
c.append(max1)
if max1 == max(a):
	c.append(max(a))
else:
	for i in a:
		h = 1
		for j in b:
			if i % j != 0:
				h = 0
				break
		if max1 % i == 0 and h == 1 and (i in b):
			c.append(i)
			break
		if max1 % i != 0:
			c.append(i)
			break
		if len(a) == 1:
			c.append(a[0])
			break
		if len(a) == 0:
			c.append(i)
			break
		a = a[1:]
print(*c)


n = int(input())
ar = list(map(int, input().split()))
c = max(ar)
d = 0
for i in range(1, c // 2 + 1):
	if c % i == 0:
		ar.remove(i)
ar.remove(c)
print(c, max(ar))


n = int(input())
array = list(map(int, input().split()))
d = max(array)
b = []
for i in range(1, d + 1):
	if d % i == 0:
		b.append(i)
for i in range(len(b)):
	array.remove(b[i])
print(d, end=' ')
print(max(array))


n = int(input())
l = list(map(int, input().split()))
m = max(l)
p = 0
for i in l:
	if m % i or l.count(i) > 1:
		p = max(p, i)
print(m, p)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
import math

def factorization(n):

	def factor_sub(n, m):
		c = 0
		while n % m == 0:
			c += 1
			n //= m
		return (c, n)
	buff = []
	(c, m) = factor_sub(n, 2)
	if c > 0:
		buff.append((2, c))
	(c, m) = factor_sub(m, 3)
	if c > 0:
		buff.append((3, c))
	x = 5
	while m >= x * x:
		(c, m) = factor_sub(m, x)
		if c > 0:
			buff.append((x, c))
		if x % 6 == 5:
			x += 2
		else:
			x += 4
	if m > 1:
		buff.append((m, 1))
	return buff

def divisor_sub(p, q):
	a = []
	for i in range(0, q + 1):
		a.append(p ** i)
	return a

def divisor(n):
	if n == 1:
		return [1]
	xs = factorization(n)
	ys = divisor_sub(xs[0][0], xs[0][1])
	for (p, q) in xs[1:]:
		ys = [x * y for x in divisor_sub(p, q) for y in ys]
	return sorted(ys)
z = divisor(x)
for i in z:
	a.remove(i)
y = a[-1]
print(x, y)


n = int(input())
a = list(map(int, input().split()))
temp = max(a)
first = []
second = []
for i in a:
	if temp % i == 0 and i not in first:
		first.append(i)
	else:
		second.append(i)
print(max(first), max(second))


n = int(input())
x = [int(q) for q in input().split()]
w = max(x)
x.remove(w)
for i in range(1, w // 2 + 1):
	if w % i == 0:
		x.remove(i)
w1 = max(x)
print(w, w1)


x = int(input())
y = map(int, input().split())
y = sorted(list(y))
f = y[-1]
l = []
f_d = [y[-1]]
for i in range(len(y) - 1):
	if f % y[i] == 0 and y[i] not in f_d:
		f_d.append(y[i])
		continue
	l.append(y[i])
print(f, max(l))


n = int(input())
d = list(map(int, input().split()))
d.sort()
big = d[-1]
facs = []
bigfacs = []
for i in range(1, int(big ** 0.5) + 1):
	if big % i == 0:
		facs.append(i)
		bigfacs.append(big // i)
if bigfacs[-1] == facs[-1]:
	bigfacs.pop()
facs += bigfacs[::-1]
ind = 0
facind = 0
while facind < len(facs):
	if facs[facind] == d[ind]:
		d.pop(ind)
		facind += 1
	else:
		ind += 1
print(big, d[-1])


from collections import Counter

def solve(n, values):
	if n == 2:
		return (values[0], values[1])
	values = sorted(values)
	if values[-1] == values[-2]:
		return (values[-1], values[-2])
	(x, index) = (values[-1], 0)
	x_values = set()
	y_values = []
	while index < n:
		value = values[index]
		if x % value == 0 and value not in x_values:
			x_values.add(value)
		else:
			y_values.append(value)
		index += 1
	return (x, y_values[-1])
n = int(input())
values = list(map(int, input().strip().split(' ')))
(x, y) = solve(n, values)
print('{} {}'.format(x, y))


n = int(input())
arr = list(map(int, input().strip().split(' ')))
arr.sort()
temp = arr[:]
int1 = max(arr)
arr.remove(int1)
k = arr[0]
arr.remove(1)
if temp[-1] != temp[-2]:
	for i in range(n - 1):
		if int1 % temp[i] == 0 and k < temp[i]:
			arr.remove(temp[i])
			k = temp[i]
	int2 = max(arr)
	print(int1, int2)
else:
	print(int1, int1)


N = int(input())
A = list(map(int, input().split()))
X = max(A)
div = set()
for i in range(1, int(X ** (1 / 2)) + 2):
	if X % i == 0:
		div.add(i)
		div.add(X // i)
f = []
for a in A:
	if a in div:
		div.remove(a)
	else:
		f += [a]
Y = max(f)
print(X, end=' ')
print(Y)


num = int(input())
list = input()
nos = list.split()
for i in range(0, len(nos)):
	nos[i] = int(nos[i])
nos.sort(reverse=True)
ans1 = nos[0]
for i in range(1, ans1 + 1):
	if ans1 % i == 0:
		for j in nos:
			if i == j:
				nos.remove(j)
				break
ans2 = nos[0]
print(ans1, ans2)


n = int(input())
p = list(map(int, input().split()))
kam = max(p)
som = [x for x in p]
jom = []
for it in p:
	if kam % it == 0 and it not in jom:
		jom.append(it)
		som.remove(it)
print(kam, max(som))


input()
d = list(sorted(map(int, input().split()), reverse=True))
i = 1
while d[0] % d[i] == 0 and d[i] != d[i - 1]:
	i += 1
print(d[0], d[i])


n = int(input())
d = [int(x) for x in input().split()]
m = max(d)
for i in range(2, m + 1):
	if m % i == 0:
		d.remove(i)
print(m, max(d))


import collections
import functools
import math
import random
import sys
import bisect
input = sys.stdin.readline

def In():
	return map(int, sys.stdin.readline().split())

def q2():
	n = int(input())
	l = collections.Counter(In())
	int1 = max(l.keys())
	for i in range(1, int(math.sqrt(int1) + 1)):
		if not int1 % i:
			l[i] -= 1
			if int1 // i != i:
				l[int1 // i] -= 1
			if not l[i]:
				l.pop(i)
			if int1 // i != i and (not l[int1 // i]):
				l.pop(int1 // i)
	print(int1, max(l.keys()))
q2()


import sys

def fprint(x):
	print(x, flush=True)

def qprint(x):
	sys.stdout.write(str(x) + '\n')

def input():
	return sys.stdin.readline()
import collections

def lcm(x, y):
	if x > y:
		greater = x
	else:
		greater = y
	return greater
n = int(input())
list_div = list(map(int, input().split()))
list_sec = []
for (item, count) in collections.Counter(list_div).items():
	if count > 1:
		list_sec.append(item)
first_num = max(list_div)
second_num = 1
for num in list_div:
	if first_num % num == 0:
		pass
	else:
		list_sec.append(num)
for num in list_sec:
	second_num = lcm(second_num, num)
print(str(first_num) + ' ' + str(second_num))


n = int(input())
d = sorted(map(int, input().split()), reverse=True)
l = d[0]
for i in range(n):
	if d[i] == d[i + 1] or l % d[i]:
		r = d[i]
		break
print(l, r)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
x = max(a)
a.reverse()
for i in a:
	if a.count(i) == 2:
		y = i
		break
	if x % i != 0:
		y = i
		break
print(str(x) + ' ' + str(y))


from math import sqrt
n = int(input())
a = [int(x) for x in input().split()]
m = max(a)
sq = sqrt(m)
new = []
for i in range(1, m + 1):
	if m % i == 0:
		new.append(i)
for i in new:
	a.remove(i)
print(m, max(a))


import sys
n = int(input())
m = list(map(int, input().split(' ')))
if n == 1:
	print(1, ' ', 1)
	sys.exit(0)
d = [0 for i in range(10001)]
for l in m:
	d[l] += 1
y = -1
m = sorted(m)
m.reverse()
x = m[0]
for l in m:
	if d[l] > 1 or x % l != 0:
		y = l
		break
print(x, ' ', y)
pass


n = int(input())
a = sorted(list(map(int, input().split())))
x = a[n - 1]
y = 1
b = [0] * 10001
for i in range(n):
	b[a[i]] += 1
for i in range(1, x + 1):
	if x % i == 0:
		b[i] -= 1
for i in range(10000, -1, -1):
	if b[i] == 1:
		y = i
		break
print(x, y)


from sys import stdin, stdout
n = int(input())
divs = list(map(int, input().split()))
mp = {}
for num in divs:
	if num not in mp.keys():
		mp[num] = 1
	else:
		mp[num] += 1
maxi = max(divs)
divs_maxi = []
for i in range(1, maxi):
	if maxi % i == 0 and i not in divs_maxi:
		divs_maxi.append(i)
		divs_maxi.append(maxi // i)
for num in set(divs_maxi):
	if num in mp.keys():
		mp[num] -= 1
maxi_2 = -1
for (k, v) in mp.items():
	if v > 0:
		maxi_2 = max(maxi_2, k)
if maxi_2 == -1:
	maxi_2 = maxi
print(str(maxi) + ' ' + str(maxi_2))


maara = int(input())
listaa = []
a = input()
b = a.split()
for numero in b:
	listaa.append(int(numero))
lista = sorted(listaa)
x = lista[-1]
jakajalista = []
for luku in lista:
	if x % luku == 0 and luku not in jakajalista:
		jakajalista.append(luku)
for luku in jakajalista:
	if luku in lista:
		lista.remove(luku)
final = sorted(lista)
y = final[-1]
print(x, end=' ')
print(y)


n = int(input())
arr = list(map(int, input().split()))
number1 = max(arr)
arr.remove(number1)
for i in range(1, number1 // 2 + 1):
	if number1 % i == 0:
		arr.remove(i)
a1 = str(number1)
a2 = str(max(arr))
print(a1, a2)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
d = 1
x = arr[n - 1]
y = 1
for i in arr:
	if arr.count(i) == 2 and i > d:
		d = i
	if x % i != 0 and i > y:
		y = i
print(x, max(d, y))


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
x = max(arr)
for i in d:
	if x % i == 0:
		d[i] -= 1
y = -1
for i in d:
	if d[i] == 1:
		y = max(y, i)
print(x, y)


n = int(input())
divisors = [int(x) for x in input().split()]
divisors.sort(reverse=True)
x = divisors[0]
last = 0
for divisor in divisors:
	if x % divisor != 0:
		y = divisor
		break
	elif divisor == last:
		y = divisor
		break
	last = divisor
if divisors[0] == divisors[1]:
	y = x
print(x, y)


n = int(input())
ara = list(map(int, input().split()))
mx = max(ara)
for i in range(1, mx + 1):
	if mx % i == 0:
		pos = ara.index(i)
		ara.pop(pos)
mx2 = max(ara)
print(mx, mx2)


n = int(input())
x = list(map(int, input().split()))
x = sorted(x)
max = x[-1]
i = len(x) - 2
while max % x[i] == 0 and (not x[i] == x[i + 1]):
	i -= 1
print(max, x[i])


n = int(input())
x = [int(k) for k in input().split(' ')]
ans = 1
a = max(x)
x1 = x.copy()
b = 1
d = []
for i in x:
	if i not in d:
		if a % i == 0:
			d.append(i)
			x1.remove(i)
b = max(x1)
print(a, b)


n = int(input())
inp = list(map(int, input().split()))
ans = [max(inp)]
inp.remove(max(inp))
for i in range(1, ans[0] // 2 + 1):
	if ans[0] % i == 0:
		inp.remove(i)
print(ans[0], max(inp))


input()
ds = list(map(int, input().split()))
x = max(ds)
for v in {v for v in ds if x % v == 0}:
	ds.remove(v)
y = max(ds)
print(x, y)


from collections import defaultdict
input()
X = list(map(int, input().split()))
D = defaultdict(int)
for i in X:
	D[i] += 1
List = sorted(D.keys(), reverse=True)
if D[List[0]] == 2:
	print(List[0], List[0])
	exit()
for i in range(1, len(List)):
	if List[0] % List[i] == 0 and D[List[i]] == 2:
		print(List[0], List[i])
		exit()
	elif List[0] % List[i] != 0:
		print(List[0], List[i])
		exit()


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = a[n - 1]
for i in range(1, n):
	if a[0] % a[i] != 0 or a[i - 1] == a[i]:
		ans = a[i]
		break
print(ans, a[0])


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
k = a[len(a) - 1]
for i in range(n - 2, -1, -1):
	if k % a[i] != 0 or a[i + 1] == a[i]:
		print(k, a[i])
		break


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
maxi = arr[0]
dd = {}
for item in arr:
	if dd.get(item) is not None:
		dd[item] += 1
	else:
		dd[item] = 1
st = set()
for item in arr:
	if maxi % item == 0:
		if item not in st:
			dd[item] -= 1
	st.add(item)
for item in arr:
	if dd[item] != 0:
		ans2 = item
		break
print(maxi, ans2)


n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
if n == 2:
	print(a[0], a[1])
else:
	x = a[0]
	just = x
	for i in range(1, n):
		if a[i] != just and x % a[i] == 0:
			just = a[i]
		else:
			y = a[i]
			break
	print(x, y)


n = int(input())
divisiors = list(map(int, input().split()))
divisiors.sort()
x = divisiors[-1]
for i in range(1, x + 1, 1):
	if x % i == 0:
		val = divisiors.index(i)
		divisiors[val] = 0
divisiors.sort()
y = divisiors[-1]
print(x, y)


n = int(input())
a = []
a = input().split()
for i in range(n):
	a[i] = int(a[i])
x = max(a)
a.sort()
y = 0
count = {}
for i in a:
	if i in count:
		count[i] += 1
	else:
		count[i] = 1
for i in a:
	if x % i != 0:
		y = i
	elif count[i] == 2:
		y = i
print(x, y)


n = int(input())
s = list(map(int, input().split()))
d = max(s)
k = []
for i in s:
	if s.count(i) == 2:
		k.append(i)
	if d % i != 0:
		k.append(i)
print(d, max(k))


def getD(num):
	res = []
	res.append(num)
	for i in range(1, num):
		if num % i == 0:
			res.append(i)
	return res
i = input()
li = [int(x) for x in input().split()]
li.sort()
m = li[len(li) - 1]
r = getD(m)
for i in r:
	for (k, v) in enumerate(li):
		if v == i:
			li[k] = 0
			break
li.sort()
print(m, ' ', li[len(li) - 1])


input()
lst = list(map(int, input().split()))
lst.sort()
d1 = lst[-1]
for i in set(lst):
	if d1 % i == 0:
		lst.remove(i)
print(d1, lst[-1])


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def invr():
	return list(map(int, input().split()))
n = inp()
d = invr()
d.sort(reverse=1)
c = [0] * (d[0] + 1)
a = d.pop(0)
c[a] = 1
b = None
al = -1
bl = -1
two = 1
for e in d:
	if a % e != 0 or c[e]:
		b = e
		break
	c[e] = 1
print(a, b)


n = int(input())
a = list(map(int, input().split()))
ans = []
for elem in a:
	isGood = True
	for elem2 in a:
		if elem2 % elem == 0 and elem2 != elem:
			isGood = False
			break
	if isGood:
		ans.append(str(elem))
if len(ans) == 2:
	print(' '.join(ans))
else:
	maxTwice = 0
	for elem in a:
		cnt = 0
		for elem2 in a:
			if elem == elem2:
				cnt += 1
		if cnt == 2 and maxTwice < elem:
			maxTwice = elem
	print(ans[0] + ' ' + str(maxTwice))


a = int(input())
b = list(map(int, input().split()))
c = max(b)
d = []
e = []
for i in b:
	if c % i == 0 and i not in d:
		d.append(i)
	else:
		e.append(i)
print(max(d), max(e))


def getDivisors(n):
	divisor = []
	i = 1
	while i <= n:
		if n % i == 0:
			(divisor.append(i),)
		i = i + 1
	return divisor
n = int(input())
divisors = input().split(' ')
for i in range(n):
	divisors[i] = int(divisors[i])
divisors.sort()
y = max(divisors)
ydiv = getDivisors(y)
for i in ydiv:
	divisors.remove(i)
x = max(divisors)
print(x, y)


input()
divisors = list(map(int, input().split()))
unique_divisors = set(divisors)
first_number = max(divisors)
[divisors.remove(d) for d in unique_divisors if first_number % d == 0]
second_number = max(divisors)
print(str(first_number) + ' ' + str(second_number))


n = int(input())
d = list(map(int, input().split()))
x = max(d)
li = []
l = []
for i in range(0, n):
	if x % d[i] != 0:
		li.append(d[i])
if len(li) != 0:
	y = max(li)
	print(x, end=' ')
	print(y)
else:
	d.sort()
	for i in range(0, n - 1):
		if d[i] == d[i + 1]:
			l.append(d[i])
	y = max(l)
	print(x, end=' ')
	print(y)


n = int(input())
(d1, d2) = (list(map(int, input().split())), [])
x = max(d1)
d1.remove(x)
for i in range(1, x // 2 + 1):
	if x % i == 0:
		d1.remove(i)
print(x, max(d1))


from collections import Counter
n = int(input())
lst = list(map(int, input().split()))
d = Counter(lst)
temp = max(lst)
print(temp, end=' ')
arr = []
for i in range(temp, 0, -1):
	if temp % i == 0:
		arr.append(i)
for i in range(len(arr)):
	d[arr[i]] -= 1
maxx = 0
for i in d:
	if d[i] == 1 and i > maxx:
		maxx = i
print(maxx)


n_length = int(input())
nums = list(map(int, list(input().split())))
nums.sort()
x = nums[-1]
div1 = []
div2 = []
for n in nums:
	if x % n == 0 and n not in div1:
		div1.append(n)
	else:
		div2.append(n)
div1.sort()
div2.sort()
print(str(div1[-1]) + ' ' + str(div2[-1]))


n = int(input())
l = list(map(int, input().split()))
x = max(l)
ans = []
count = {}
for i in l:
	if x % i != 0 or count.get(i, 0) != 0:
		ans.append(i)
	else:
		count[i] = 1
print(x, max(ans))


import re, math, decimal, bisect, collections

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
iread()
nums = sorted(viread())
x = nums[-1]
found = []
for y in nums[::-1]:
	if x % y != 0 or y in found:
		print(x, y)
		break
	else:
		found.append(y)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
n = int(input())
a = list(map(int, input().split()))
a.sort()
one = a[-1]
b = []
for i in range(n - 2, -1, -1):
	if one % a[i] == 0:
		if a[i] in a[i + 1:]:
			b.append(a[i])
	else:
		b.append(a[i])
two = 0
if len(b) == 0:
	two = a[0]
elif len(b) == 1:
	two = b[0]
else:
	lc = b[0] * b[1] // gcd(b[0], b[1])
	for i in range(2, len(b)):
		lc = lc * b[i] // gcd(lc, b[i])
	two = lc
print(one, two)


n = int(input())
A = list(map(int, input().split()))
x = max(A)
from collections import Counter
counter = Counter(A)
import math
xr = math.ceil(math.sqrt(x))
LIST = []
for i in range(1, xr + 1):
	if x % i == 0:
		LIST.append(i)
		LIST.append(x // i)
LIST = set(LIST)
for l in LIST:
	counter[l] -= 1
REST = [i for i in list(counter.keys()) if counter[i] != 0]
y = max(REST)
print(x, y)


n = int(input())
D = [*map(int, input().split())]
k = min(D) * max(D)
t = 0
Z = list(set(D))
for i in range(len(Z)):
	if k % Z[i] == 0:
		D.remove(Z[i])
p = min(D) * max(D)
print(k, p)


n = int(input())
v = list(map(int, input().split()))
v.sort()
y = max(v)
x = 0
li = -1
for j in range(n):
	i = v[j]
	if i != li:
		if y % i != 0:
			if i > x:
				x = i
	elif i > x:
		x = i
	li = i
print(y, x)


n = int(input())
nums = list(map(int, input().strip().split()))
num1 = max(nums)
num2 = 1
nums1 = []
for i in range(n):
	if num1 % nums[i] == 0:
		if not nums[i] in nums1:
			nums1.append(nums[i])
			continue
	if nums[i] > num2:
		num2 = nums[i]
print(num1, num2)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	n = int(input())
	arr = get_array()
	arr.sort()
	x = arr[-1]
	if arr[-1] == arr[-2]:
		print(x, x)
		return
	for i in range(n - 2, 0, -1):
		if arr[i] == arr[i - 1]:
			print(x, arr[i])
			return
		elif x % arr[i] != 0:
			print(x, arr[i])
			return
main()


n = int(input())
L = list(map(int, input().split()))
x = []
s = max(L)
print(s, end=' ')
for i in range(n):
	if s % L[i] == 0 and (not L[i] in x):
		x.append(L[i])
		L[i] = 0
print(max(L))


n = int(input())
ls = list(map(int, input().split()))
l = max(ls)
m = 1
import collections
dic = collections.Counter(ls)
for i in ls:
	if l % i != 0 and i > m:
		m = i
	elif dic[i] == 2 and i > m:
		m = i
print(l, m)


n = int(input())
arr = list(map(int, input().strip().split(' ')))
arr.sort(reverse=True)
i = arr[0]
for j in arr:
	if arr.count(j) > 1 or i % j:
		print(i, j)
		break


from collections import Counter
n = int(input())
a = [int(o) for o in input().split()]
a = sorted(a)
m = a[-1]
z = []
z1 = dict(Counter(a))
lol = []
for i in range(len(a)):
	if z1[a[i]] == 2:
		lol.append(a[i])
	if m % a[i] != 0:
		z.append(a[i])
try:
	print(m, z[-1])
except:
	print(m, lol[-1])


def div(a):
	d = max(a)
	for i in range(2, d + 1):
		if d % i == 0:
			a.remove(i)
	print(d, max(a))
n = int(input())
a = list(map(int, input().split()))
div(a)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
d_x = set()
for di in d:
	if x % di == 0:
		d_x.add(di)
d_x = list(d_x)
for d_xi in d_x:
	d.remove(d_xi)
y = max(d)
print(x, y)


n = int(input())
t = list(map(int, input().split()))
t.sort()
X = t[-1]
x = []
y = []
for k in range(n):
	if X % t[k] == 0:
		if t[k] not in x:
			x.append(t[k])
		else:
			y.append(t[k])
	else:
		y.append(t[k])
y.sort()
print(X, y[-1])


n = int(input())
divisors = [int(x) for x in input().split()]

def hcf(a, b):
	while a != b:
		if a > b:
			a = a - b
		else:
			b = b - a
	return a

def lcm(a, b):
	h = hcf(a, b)
	return a * b // h
div = sorted(divisors)
a = div[-1]
b = 1
for (i, x) in enumerate(div):
	if x == div[i - 1]:
		b = lcm(b, x)
	if a % x != 0:
		b = lcm(b, x)
print(a, b)


n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(n - 1, -1, -1):
	if L[-1] % L[a] == 0 and L[a] == L[a - 1]:
		print(L[-1], L[a])
		exit()
	if L[-1] % L[a] != 0:
		print(L[-1], L[a])
		exit()


n = int(input())
l = list(map(int, input().split()))
l1 = []
cout = max(l)
i = 0
while i < len(l):
	if cout % l[i] == 0 and l[i] not in l1:
		l1.append(l[i])
		l.remove(l[i])
	else:
		i += 1
print(cout, max(l))


n = int(input())
A = list(map(int, input().split()))
x = max(A)
for a in {a for a in A if x % a == 0}:
	A.remove(a)
print(x, max(A))


n = int(input())
D = list(map(int, input().split()))
D.sort(reverse=True)
x = D.pop(0)
for i in range(1, x):
	if x % i == 0:
		D.remove(i)
print(x, max(D))


n = int(input())
d = input().split()
for j in range(n):
	d[j] = int(d[j])
y = max(d)
r = set(d)
a = []
for i in r:
	if y % i == 0:
		d.remove(i)
print(y, max(d))


n = int(input())
s = input()
li = s.split(' ')
for i in range(len(li)):
	li[i] = int(li[i])
li.sort(reverse=True)
a = li[0]
li2 = []
i = 0
while i < n:
	if a % li[i] == 0 and li[i] not in li2:
		li2.append(li[i])
		del li[i]
		i -= 1
		n -= 1
	i += 1
print(li[0])
print(li2[0])


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_elements = read_int()
numbers = read_ints()
one = max(numbers)
sec = -one
for i in numbers:
	if one % i or numbers.count(i) > 1:
		sec = max(sec, i)
print(one, sec)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
a = sorted(a)
i = 1
maxm = a[n - 1]
while i * i <= maxm:
	if maxm % i == 0:
		a.remove(i)
		if i * i != maxm:
			a.remove(maxm // i)
	i += 1
print(str(maxm) + ' ' + str(max(a)))


n = int(input())
d = list(map(int, input().split()))
m = max(d)
s = set()
t = set()
for i in d:
	if m % i == 0 and i not in s:
		s.add(i)
	else:
		t.add(i)
print(m, max(t))


n = int(input())
divisors = [int(x) for x in input().split(' ')]
x = max(divisors)
x_d = []
y_d = []
for i in divisors:
	if x % i == 0 and i not in x_d:
		x_d.append(i)
	else:
		y_d.append(i)
y = max(y_d)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
x = a[-1]
y = 0
div_x = list()
for i in range(n):
	if x % a[i] == 0:
		if a[i] not in div_x:
			div_x.append(a[i])
dic = {}
for i in a:
	if i in dic.keys():
		dic[i] += 1
	else:
		dic[i] = 1
for i in div_x:
	dic[i] -= 1
	if dic[i] == 0:
		dic.pop(i)
y = max(dic.keys())
print(x, y)


import math
n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
t = []
for i in range(n):
	if a % l[i] == 0 and l[i] not in t:
		t.append(l[i])
		l[i] = 0
l.sort()
b = l[-1]
print(a, b)


from collections import Counter
import math
n = int(input().strip())
a = [int(x) for x in input().strip().split(' ')]
p = max(a)
c = Counter(a)
i = 1
while i <= math.sqrt(p):
	if p % i == 0:
		if p / i == i:
			c[i] -= 1
		else:
			c[i] -= 1
			c[int(p / i)] -= 1
	i = i + 1
l = []
for i in c.keys():
	if c[i]:
		l.append(i)
if l == []:
	print(p, p)
else:
	print(p, max(l))


from collections import Counter
n = int(input())
l = list(map(int, input().split(' ')))
c = Counter(l)
a = max(l)

def divs(n):
	ans = []
	for i in range(1, n + 1):
		if n % i == 0:
			ans.append(i)
	return ans
div = divs(a)
for elm in div:
	c[elm] -= 1
rest = []
for key in c:
	if c[key] > 0:
		rest.append(key)
b = max(rest)
print(a, b)


import sys
import math
input = sys.stdin.readline

def lcm(n1, n2):
	gcd = math.gcd(n1, n2)
	result = n1 * n2 / gcd
	return int(result)
n = int(input())
b = list(map(int, input().split()))
c = dict()
for j in b:
	if j in c.keys():
		c[j] += 1
	else:
		c[j] = 1
a = list(set(b))
k = max(a)
p = 1
q = 1
for j in a:
	if c[j] == 2:
		p = lcm(p, j)
		q = lcm(q, j)
	else:
		p = lcm(p, j)
print(k, p * q // k)


n = int(input())
d = [int(x) for x in input().split()]
d.sort()
y = d[-1]
if d[-2] == d[-1]:
	print(d[-1], d[-2])
else:
	for i in range(n - 2, -1, -1):
		if y % d[i] != 0 or d[i] == d[i - 1]:
			print(d[i], y)
			break
	else:
		print(d[-1], 1)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
y = 1
o = 1
f = [True for i in range(10001)]
for i in a:
	if x % i == 0 and f[i]:
		f[i] = False
	else:
		o = i
print(x, o)


def find_x_y(n, divisors):
	divis = sorted(divisors)
	if divis[-1] == divis[-2]:
		return (divis[-1], divis[-2])
	else:
		x = divis[-1]
		temp = 0
		n -= 2
		while n >= 0:
			if x % divis[n] != 0:
				return (x, divis[n])
			elif divis[n] == temp:
				return (x, divis[n])
			else:
				temp = divis[n]
			n -= 1
n = int(input())
divisors = list(map(int, input().split()))
(x, y) = find_x_y(n, divisors)
print(x, y)


import math
n = int(input())
arr = [int(x) for x in input().split()]
l = len(arr)
arr.sort()
P = arr[l - 1]
divOfP = []
r = int(math.sqrt(P)) + 1
for i in range(1, r):
	if P % i == 0:
		if i * i == P:
			divOfP.append(i)
		else:
			divOfP.append(i)
			divOfP.append(P // i)
for x in divOfP:
	arr.remove(x)
l = len(arr)
if l == 0:
	P = Q
else:
	Q = arr[l - 1]
print(P, Q)
divOfP.clear()
arr.clear()


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
y = arr[-1]
j = n - 2
if arr[-1] == arr[-2]:
	print(arr[-1], arr[-1])
else:
	while j > 0:
		if y % arr[j] != 0:
			break
		elif arr[j] == arr[j - 1]:
			break
		else:
			j -= 1
	print(arr[j], y)


import sys
from math import *

def lcm(a, b):
	m = a * b
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return m // (a + b)
n = int(input())
if n == 2:
	print(1, 1)
	exit()
dat = [int(i) for i in input().split()]
a = max(dat)
for i in range(1, a + 1):
	if a % i == 0:
		dat.remove(i)
b = max(dat)
print(a, b)


n = input()
x = sorted(list(map(int, input().split())), reverse=True)
i = x[0]
for j in x:
	if x.count(j) > 1 or i % j:
		print(i, j)
		exit(0)


from math import *
n = int(input())
a = list(map(int, input().split()))
s = 0
r = 0
g = 0
b = 0
x = max(a)
a.remove(x)
for i in range(1, x):
	if x % i == 0:
		a.remove(i)
print(x, max(a))


import math
final = []

def printDivisors(n):
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				final.append(i)
			else:
				final.append(i)
				final.append(n // i)
		i = i + 1
n = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
print(l[0], end=' ')
printDivisors(l[0])
for i in range(len(final)):
	l.remove(final[i])
print(l[0])


n = int(input())
l = list(map(int, input().split()))
m = max(l)
l.remove(m)
for i in range(2, m // 2 + 1):
	if m % i == 0:
		l.remove(i)
print(str(m) + ' ' + str(max(l)))


n = int(input())
l = list(map(int, input().split()))
maxi = max(l)
for i in range(1, maxi + 1):
	if maxi % i == 0:
		l.remove(i)
print(maxi, max(l))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
x = arr[-1]
flag = 1
if n == 2:
	print(arr[0], arr[1])
else:
	for i in range(n - 2, -1, -1):
		if x % arr[i] != 0:
			y = arr[i]
			flag = 0
			break
	if flag:
		for i in range(n - 1, 0, -1):
			if arr[i] == arr[i - 1]:
				y = arr[i]
				break
	print(x, y)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
n1 = a[-1]
n2 = 0
if n1 == a[-2]:
	n2 = n1
else:
	l = Counter(a)
	for i in range(n - 1, -1, -1):
		if n1 % a[i] == 0:
			if l[a[i]] >= 2:
				n2 = a[i]
				break
		else:
			n2 = a[i]
			break
print(n2, n1)


n = int(input())
cl = list(map(int, input().split()))
mx = max(cl)
d = []
res = []
for x in cl:
	if mx % x == 0 and x not in d:
		d.append(x)
	else:
		res.append(x)
print(mx, max(res))


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
divs = []
for z in range(1, x + 1):
	if x % z == 0:
		arr.pop(arr.index(z))
print(x, max(arr))


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
print(max(a), end=' ')
mx1 = 1
s = []
a.remove(mx)
for i in range(2, mx // 2 + 1):
	if mx % i == 0:
		s.append(i)
for i in s:
	a.remove(i)
print(max(a))


n = int(input())
ar = sorted(list(map(int, input().split())), reverse=True)
x = max(ar)
for i in set(ar):
	if x % i == 0:
		ar.remove(i)
print(x, ar[0])


n = int(input())
d = list(map(int, input().split()))
d.sort()
a = d[-1]
(x, y) = ([], [])
for i in range(n):
	if a % d[i] == 0 and d[i] not in x:
		x.append(d[i])
	else:
		y.append(d[i])
print(a, max(y))


import math
n = int(input())
d = list(map(int, input().split()))
gcd_number = 1
for i in range(len(d)):
	if d.count(d[i]) == 2 and d[i] > gcd_number:
		gcd_number = d[i]
x = max(d)
y = 0
for elem in d:
	if math.gcd(elem, x) == gcd_number and elem > y:
		y = elem
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a.sort()
num = max(a)
d = dict()
for i in range(n):
	d[a[i]] = 0
for i in range(n):
	d[a[i]] += 1
a = list(set(a))
v = []
for i in range(len(a)):
	if d[a[i]] == 2 or num % a[i] != 0:
		v.append(a[i])
num2 = max(v)
print(num, num2)


n = int(input())
l = list(map(int, input().split()))
t = list(set(l))
t.sort()
x = t[-1]
print(x, end=' ')
for i in t:
	if x % i == 0:
		l.remove(i)
l.sort()
y = l[-1]
print(y)


x = int(input())
l = [int(x) for x in input().split()]
i = 0
l.sort(reverse=False)
maxi = max(l)
for i in range(1, maxi + 1):
	if maxi % i == 0:
		l.remove(i)
		i -= 1
	i += 1
maxx = 0
maxx = max(l)
print(maxi, maxx)


s = input()
a = input().split()
a = list(map(int, a))
a = sorted(a)
first = a[-1]
m = -1
pred = -1
for i in a:
	if first % i == 0:
		if pred == i:
			m = max(m, i)
	else:
		m = max(m, i)
	pred = i
print(first, m)


def get_factors(num):
	l = [1, num]
	for i in range(2, int(num ** 0.5) + 1):
		if not num % i:
			if i not in l:
				l.append(i)
				if num // i not in l:
					l.append(num // i)
	return l
n = int(input())
l = list(map(int, input().rstrip().split(' ')))
if n == 2:
	print(l[1], l[0])
else:
	l.sort()
	n1 = l[-1]
	print(n1, end=' ')
	fac_n1 = get_factors(n1)
	fac_n1.sort()
	b = 0
	for i in range(n):
		if l[i] == fac_n1[b]:
			l[i] = 0
			b += 1
		if b == len(fac_n1):
			break
	print(max(l))


n = int(input())
l = [int(x) for x in input().split()]
l = sorted(l)
j = l[n - 1]
k = list(set(l))
for i in k:
	if j % i == 0:
		l.remove(i)
print(j, max(l))


n = int(input())
l = list(map(int, input().split()))
l1 = [max(l)]

def factors(n):
	i = 1
	s = set()
	while i * i <= n:
		if n % i == 0:
			s.add(i)
			s.add(n // i)
		i += 1
	return list(s)
l2 = factors(max(l))
for i in l2:
	l.remove(i)
l1.append(max(l))
print(*l1)


t = int(input())
a = list(map(int, input().strip().split()))[:t]
c1 = max(a)
b = []
for i in range(1, c1):
	if c1 % i == 0:
		b.append(i)
m = len(b)
for j in range(m):
	d = b[j]
	a.remove(d)
a.remove(c1)
c2 = max(a)
print(c1, ' ', c2)


n = int(input())
mx = 1
a = list(map(int, input().split()))
b = set(a.copy())
for i in a:
	mx = max(mx, i)
for i in b:
	if mx % i == 0:
		a.remove(i)
mxx = 1
for i in a:
	mxx = max(mxx, i)
print(mx, mxx)


n = int(input())
lista = input()
lista = list(map(int, lista.split()))
lista = sorted(lista)
i = -1
x = lista[-1]
print(x, '', end='')
while i < 0:
	if lista[i] == lista[i - 1] or x % lista[i] != 0:
		print(lista[i])
		break
	i -= 1


n = int(input())
L = list(map(int, input().split()))
x = max(L)
s1 = set()
s2 = set()
maxnon = 0
for i in L:
	if x % i != 0 and i > maxnon:
		maxnon = i
	elif x % i == 0:
		if i not in s1:
			s1.add(i)
		else:
			s2.add(i)
if maxnon != 0:
	print(' '.join([str(x), str(maxnon)]))
else:
	print(' '.join([str(x), str(max(s2))]))


n = int(input())
a = input().split(' ')
b = list(map(int, a))
b.sort()
print(b[n - 1], end=' ')
f = 0
p = 0
for j in range(2, n):
	if b[n - 1] % b[n - j] != 0:
		f = 1
		break
if f == 1:
	print(b[n - j])
else:
	for i in range(n - 1, -1, -1):
		if b[i] == b[i - 1]:
			print(b[i])
			break


class CodeforcesTask1108BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.divisors = []

	def read_input(self):
		self.n = int(input())
		self.divisors = [int(x) for x in input().split(' ')]

	def process_task(self):
		self.divisors.sort(reverse=True)
		a = self.divisors.pop(0)
		used = [a]
		chanded = True
		while chanded:
			chanded = False
			for x in self.divisors:
				if not a % x and x not in used:
					used.append(x)
					chanded = True
					self.divisors.remove(x)
		b = self.divisors.pop(0)
		self.result = '{0} {1}'.format(a, b)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1108BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def solve():
	n = int(input())
	mydct = {}
	for i in map(int, input().split()):
		mydct[i] = mydct.setdefault(i, 0) + 1
	a = max(mydct)
	for i in mydct.copy():
		if a % i == 0:
			mydct[i] -= 1
		if mydct[i] == 0:
			mydct.pop(i)
	b = max(mydct)
	print(a, b)
solve()


n = int(input())
arr = list(map(int, input().strip().split(' ')))
arr.sort()
x = arr[-1]
for i in range(n - 2, -1, -1):
	if x % arr[i] == 0 and arr.count(arr[i]) > 1 or x % arr[i] != 0:
		y = arr[i]
		break
print(x, y)


n = int(input())
l = sorted([int(i) for i in input().split()])
y = l[-1]
l = l[:-1]
temp = y
while l != []:
	x = l[-1]
	if y % x != 0:
		print(x, y)
		break
	elif temp == x:
		print(x, y)
		break
	else:
		temp = x
		l = l[:-1]


a = int(input())
b = list(map(int, input().split()))
x = max(b)
print(x, end=' ')
delki = []
for i in range(1, x + 1):
	if x % i == 0:
		delki.append(i)
for j in delki:
	if j in b:
		del b[b.index(j)]
print(max(b))


from math import sqrt
n = int(input())
inp = [int(x) for x in input().split()]
x = y = 0
freq = [0] * 10001
for i in inp:
	freq[i] += 1
	x = max(x, i)
fact = x
for i in range(1, int(sqrt(fact)) + 1):
	if fact % i == 0:
		div = fact // i
		if i == div:
			freq[i] -= 1
		else:
			freq[i] -= 1
			freq[div] -= 1
for i in range(1, 10001):
	if freq[i] != 0:
		y = max(y, i)
print(f'{x} {y}')


n = int(input())
s = [int(elem) for elem in input().split()]
a = 1
b = 1
x = max(s)
s2 = []
used = [False] * 10001
for i in range(n):
	if x % s[i] != 0 or used[s[i]]:
		s2.append(s[i])
	else:
		used[s[i]] = True
print(x, end=' ')
if len(s2) > 0:
	y = max(s2)
	print(y)
else:
	print(1)


n = int(input())
d = list(map(int, input().split()))
f = {}
for i in d:
	if i in f:
		f[i] += 1
	else:
		f[i] = 1
one = max(d)
two = [1 for i in range(len(d))]
for div in range(len(d)):
	if one % d[div] == 0 and f[d[div]] == 1:
		two[div] = 0
three = []
for i in range(len(two)):
	if two[i] == 1:
		three.append(d[i])
print(one, max(three))


n = int(input())
a = list(map(int, input().split()))
x = max(a)
for i in range(1, x + 1):
	if x % i == 0:
		for y in range(len(a)):
			if a[y] == i:
				a.pop(y)
				break
print(x, max(a))


length = int(input())
seq = list(map(int, input().split()))
seq.sort()
x = seq[-1]
count = {val: 0 for val in seq}
new_seq = []
for k in seq:
	if x % k:
		new_seq.append(k)
	elif not x % k and count[k]:
		new_seq.append(k)
	else:
		count[k] += 1
y = new_seq[-1]
print(x, y)


n = int(input())
s = sorted(map(int, input().split()))
ans = s[-1]
for i in range(n - 1, -1, -1):
	if ans % s[i] or s.count(s[i]) > 1:
		print(ans, s[i])
		break


from math import *
n = int(input())
l = list(map(int, input().strip().split()))
l.sort()
d = []
a = l[-1]
for i in range(1, a + 1):
	if a % i == 0:
		l.remove(i)
print(max(l), a)


import math
n = int(input())
a = [*map(int, input().split())]
m = max(a)
for i in range(int(math.sqrt(m))):
	if m % (i + 1) == 0:
		a.remove(i + 1)
		if i + 1 != int(m / (i + 1)):
			a.remove(int(m / (i + 1)))
print(' '.join(map(str, [m, max(a)])))


import math

def factors(n):
	s = set([])
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				s.add(i)
			else:
				s.add(i)
				s.add(n // i)
		i = i + 1
	return s
n = int(input())
a = list(map(int, input().split()))
num1 = max(a)
fac = factors(num1)
m = 0
d = set([])
for i in a:
	if a.count(i) >= 2:
		d.add(i)
	elif num1 % i != 0:
		d.add(i)
print(num1, max(list(d)))


from collections import Counter
N = int(input())
dividors = list(map(int, input().split()))
d1 = max(dividors)
dc = Counter(dividors)
cands = set(dc.keys())
dc1 = [v for v in cands if d1 % v == 0]
print(d1, max((dc - Counter(dc1)).keys()))


n = int(input())
d = [int(i) for i in input().split()]
x = max(d)
d = sorted(d, reverse=True)
for i in d[1:]:
	if x % i != 0 or d.count(i) > 1:
		y = i
		break
print(x, y)


n = int(input())
x = list(map(int, input().split(' ')))
x.sort()
a = x[-1]
b = x[-2]
i = -3
while a % b == 0 and a != b:
	c = x[i]
	if b == c:
		print(a, b)
		break
	else:
		b = c
		i = i - 1
else:
	print(a, b)


k = int(input())
dic = {}
x = -1
for a in map(int, input().split()):
	if a > x:
		x = a
	if a in dic.keys():
		dic.update({a: dic.get(a) + 1})
	else:
		dic.update({a: 1})
y = -1
for b in range(1, x + 1):
	if b in dic.keys():
		if x % b == 0 and dic.get(b) == 2 and (b > y):
			y = b
		if x % b != 0 and b > y:
			y = b
print(f'{x} {y}')


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
x = a[-1]
for i in range(len(a) - 2, -1, -1):
	if a[-1] % a[i] != 0 or a[i] == a[i + 1]:
		ans = a[i]
		break
print(x, ans)


input()
l = sorted(map(int, input().split()))
b = max(l)
x = [i for i in l if b % i == 0]
for i in list(set(x)):
	l.remove(i)
print(b, max(l))


import math

def divisors(n):
	divs = [1]
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			divs.extend([i, n / i])
	divs.extend([n])
	return list(set(divs))
n = int(input())
x = list(map(int, input().split()))
m1 = max(x)
mas = divisors(m1)
for i in mas:
	temp = x.pop(x.index(i))
print(m1, max(x))


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans1 = a[0]
for i in range(0, n):
	if ans1 % a[i] != 0:
		print(ans1, a[i])
		break
	elif i and a[i] == a[i - 1]:
		print(ans1, a[i])
		break


_ = int(input())
a = list(map(int, input().split()))
a = sorted(a)
res1 = a[-1]
d = {}
a2 = []
for e in a:
	if res1 % e == 0 and e not in d:
		d[e] = 1
	else:
		a2.append(e)
res2 = a2[-1]
print(res1, res2)


n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[-1], end=' ')
for i in range(n - 2, -1, -1):
	if d[n - 1] % d[i] != 0:
		print(d[i])
		break
	if d[i] == d[i + 1]:
		print(d[i])
		break


n = int(input())
a = list(map(int, input().split()))
x = max(a)
tmp = {}
for i in range(n):
	if x % a[i] == 0 and tmp.get(a[i], -2) == -2:
		tmp[a[i]] = -1
		a[i] = -1
print(x, max(a))


input()
mylist = list(map(int, input().split()))
a = max(mylist)
for i in range(2, a + 1):
	if a % i == 0:
		mylist.remove(i)
print(a, max(mylist))


import sys
inf = float('inf')

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()
n = int(input())
l = get_array()
l.sort()
div = []
a = l[-1]
for i in range(len(l)):
	if l[-1] % l[i] == 0 and l[i] not in div:
		div.append(l[i])
for i in div:
	if i in l:
		l.remove(i)
l.sort()
print(a, l[-1])


import sys
from math import ceil
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
for _ in range(1):
	n = cin()
	d = li()
	d.sort()
	(x, y) = (d[-1], 0)
	for i in range(n - 2, -1, -1):
		if x % d[i] != 0:
			y = d[i]
			break
		elif d[i] == d[i + 1]:
			y = d[i]
			break
	print(x, y)


n = int(input())
a = [int(j) for j in input().split()]
x = max(a)
y = 1
for i in range(1, x + 1):
	if x % i == 0:
		a.remove(i)
y = max(a)
print(x, y)


n = int(input())
dlist = list(map(int, input().split()))
dlist.sort()
j = 1
while True:
	j += 1
	if dlist[-j] == dlist[-j + 1]:
		break
	if not dlist[-1] % dlist[-j] == 0:
		break
print(dlist[-1], dlist[-j])


n = int(input())
nums = sorted(map(int, input().split()), reverse=True)
x = nums[0]
i = 0
p = 0
while i < len(nums):
	num = nums[i]
	if x % num == 0 and num != p:
		p = nums.pop(i)
	else:
		i += 1
print(x, nums[0])


n = int(input())
l = [*map(int, input().split())]
l.sort()
x = l[-1]
xl = set([i for i in range(1, x + 1) if x % i == 0])
seen = set()
y = 1
for e in l:
	if e not in seen:
		if e in xl:
			seen.add(e)
		else:
			y = max(y, e)
	else:
		y = max(y, e)
print(x, y)


n = int(input())
a = [int(i) for i in input().split()]
max = 0
for i in a:
	if i > max:
		max = i
a.sort()
a.reverse()
print(max, end=' ')
for i in range(len(a)):
	if max % a[i] == 0:
		if a[i] == a[i + 1]:
			print(a[i])
			break
		continue
	else:
		print(a[i])
		break


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
y = 0
for v in arr:
	if x % v != 0:
		if v > y:
			y = v
if y > 0:
	print('{0} {1}'.format(x, y))
else:
	dict = {}
	for k in arr:
		if k in dict:
			if k > y:
				y = k
		else:
			dict[k] = k
	print('{0} {1}'.format(x, y))


import math
inp_int = int(input())
inp = list(map(int, input().split()))
ans1 = max(inp)
for i in range(1, int(math.sqrt(ans1)) + 1):
	if ans1 % i == 0:
		inp.remove(i)
		if i != ans1 // i:
			inp.remove(ans1 // i)
print(ans1, max(inp))


N = int(input())
P = list(map(int, input().split(' ')))
p = len(P)
num = max(P)
yakusuu_array = []
for i in range(1, num):
	if num % i == 0:
		yakusuu_array.append(i)
yakusuu_array.append(num)
m = len(yakusuu_array)
for j in range(m):
	d = yakusuu_array[j]
	P.remove(d)
num1 = max(P)
print(int(num), ' ', int(num1))


n = int(input())
A = list(map(int, input().split()))
A.sort()
x = A[-1]
used = [0] * (x + 1)
y = 0
for i in A:
	if x % i == 0:
		if used[i] == 1:
			y = max(y, i)
		else:
			used[i] = 1
	else:
		y = max(y, i)
print(x, y)


n = int(input())
arr = [int(x) for x in input().split(' ')]
arr.sort(reverse=True)
temp = []
x = arr[0]
y = -1
for i in range(0, n):
	if x % arr[i] == 0 and arr[i] not in temp:
		temp.append(arr[i])
		arr[i] = -1
for i in arr:
	if i != -1:
		y = i
		break
print(x, y, sep=' ')


n = int(input())
a = input().split()
mn = -1
min = -1
b = []
sum = 0
len = a.__len__()
for i in range(0, len):
	a[i] = int(a[i])
a.sort(key=None, reverse=True)
mn = int(a[0])
min = int(a[1])
if min != mn:
	len = a.__len__()
	for i in range(1, len):
		if mn % a[i] != 0:
			min = a[i]
			break
		if i != len - 1:
			if a[i] == a[i + 1]:
				min = a[i]
				break
		else:
			min = a[i]
print(str(mn) + ' ' + str(min))


input()
a = list(map(int, input().split()))
a.sort(reverse=True)
x = a[0]
y1 = x + 1
for y in a:
	if x % y or y == y1:
		print(x, y)
		break
	y1 = y


def _gcd(a, b):
	if b == 0:
		return a
	else:
		return _gcd(b, a % b)

def gcd(a, b):
	if a == b:
		return a
	elif a > b:
		return _gcd(a, b)
	else:
		return _gcd(b, a)
n = int(input())
d = list(map(int, input().split()))
d.sort(reverse=True)
a = d[0]
b = 1
for i in range(n - 1):
	if d[i] == d[i + 1]:
		b = d[i]
		break
for i in range(1, n):
	if a % d[i] != 0:
		b = d[i]
		break
print('%d %d' % (a, b))


def div(x, d):
	l = []
	i = 1
	while i <= x:
		if x % i == 0:
			l.append(i)
		i += 1
	return l
n = int(input())
divisors = sorted(list(map(int, input().split())))
a = list(set(divisors))
x = max(divisors)
y = div(x, divisors)
while len(y) != 0:
	divisors.remove(y[-1])
	y.pop()
y = max(divisors)
print(x, y)


n = int(input())
l = list(map(int, input().split()))
x = max(l)
l1 = []
l1.append(1)
for i in range(n):
	if l.count(l[i]) > 1:
		l1.append(l[i])
	elif x % l[i] != 0:
		l1.append(l[i])
l1.sort()
print(x, max(l1))


n = int(input())
a = list(map(int, input().split()))
x = max(a)
l = []
a.sort()
for i in range(n - 1):
	if a[i] == a[i + 1]:
		l.append(a[i])
i = 0
while i < len(a):
	if x % a[i] == 0:
		a.pop(i)
	else:
		i += 1
i = 0
while len(l) > 0:
	va = l.pop()
	a.append(va)
y = max(a)
print(x, y)


n = int(input())
a = sorted(map(int, input().split()))
z = max(a)
s = set()
if len(set(a)) == len(a) // 2:
	print(max(a), max(a))
else:
	for i in sorted(set(a)):
		if z % i != 0:
			s.add(i)
		if a.count(i) == 2:
			s.add(i)
	print(z, max(s))


n = int(input())
count = 1
array = list(map(int, input().split()))
array.sort()
num1 = array.pop()
garv = [num1]
for i in range(len(array)):
	if num1 % array[i] == 0 and array[i] not in garv:
		garv.append(array[i])
		array[i] = 0
print(num1, sorted(list(set(array)))[-1])


n = int(input())
a = [int(x) for x in input().split()]
ans1 = max(a)
for i in range(1, ans1 + 1):
	if ans1 % i == 0:
		a.remove(i)
print(ans1, max(a))


def divisor(n, array):
	array.sort()
	ans1 = array[-1]
	for i in range(1, array[-1] + 1):
		if array[-1] % i == 0:
			array.remove(i)
	ans2 = array[-1]
	return [ans1, ans2]
n = int(input())
array = list(map(int, input().split(' ')))
(ans1, ans2) = divisor(n, array)
print(ans1, ans2)


def Diff(li1, li2):
	li_dif = [i for i in a if not i in b or b.remove(i)]
	return li_dif
n = int(input())
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
maxi = max(a)
print(maxi, end=' ')
b = []
for i in range(1, maxi + 1):
	if maxi % i == 0:
		b.append(i)
c = Diff(a, b)
print(max(c))


n = int(input())
num = list(map(int, input().split()))
x = max(num)
print(x, max((y for y in num if x % y or num.count(y) > 1)))


from math import sqrt
n = int(input())
d = list(map(int, input().split()))
x = max(d)
for i in range(1, int(sqrt(x)) + 1):
	if x % i == 0:
		d.remove(i)
		if i != int(x / i):
			d.remove(int(x / i))
y = max(d)
print(x, y)


def ls(l, n):
	desc = sorted(l, reverse=True)
	n1 = desc[0]
	l1 = []
	l2 = []
	for i in range(1, len(desc)):
		if n1 % desc[i] or desc.count(desc[i]) > 1:
			print(n1, desc[i])
			return
n = int(input())
ls(list(map(int, input().rstrip().split())), n)


n = int(input())
d = input().split(' ')
d_int = []
for i in d:
	d_int.append(int(i))
d = d_int
x = max(d)
for i in range(1, int(x ** 0.5) + 1):
	if x % i == 0:
		d.remove(i)
		if i != x // i:
			d.remove(x // i)
print(x, max(d))


n = int(input())
a = [int(x) for x in input().split()]
ans1 = max(a)
print(ans1, max([y for y in a if ans1 % y or a.count(y) > 1]))


from math import ceil

def get_divisor(x):
	l = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			l.append(i)
			if i != x // i:
				l.append(x // i)
	return l
(n, l) = (int(input()), list(map(int, input().split())))
l.sort(reverse=True)
l1 = get_divisor(l[0])
for i in range(1, n):
	if sorted(l1 + get_divisor(l[i]), reverse=True) == l:
		print(l[0], l[i])
		exit(0)


from collections import defaultdict

def inpl():
	return [int(i) for i in input().split()]
N = input()
T = inpl()
H = defaultdict(lambda : False)
a = max(T)
ans = 0
for t in T:
	if a % t or H[t]:
		ans = max(ans, t)
	else:
		H[t] = True
print(*(a, ans))


import math
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
if arr[-1] == arr[-2]:
	print(arr[-1], arr[-1])
	exit()
for i in range(n - 2, -1, -1):
	if arr[-1] % arr[i] != 0 or arr.count(arr[i]) == 2:
		print(arr[-1], arr[i])
		exit()


from math import *
n = int(input())
a = list(map(int, input().split()))
x = max(a)
b = []
for i in range(1, x + 1):
	if x % i == 0:
		b.append(i)
for i in range(0, len(b)):
	for j in range(0, len(a)):
		if b[i] == a[j]:
			del a[j]
			break
print(x, max(a))


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
x = max(l)
m = set()
ll = l[:]
for e in ll:
	if x % e == 0 and e not in m:
		m.add(e)
		l.remove(e)
print(x, max(l))


n = int(input())
str_arr = input().split(' ')
a = [int(num) for num in str_arr]
n1 = max(a)
for j in range(1, n1 + 1):
	if n1 % j == 0:
		a.remove(j)
n2 = max(a)
print(n1, n2)


n = int(input())
l = list(map(int, input().split(' ')))
l.sort(reverse=True)
flag = [False] * n
(a, b, s) = (l[0], 0, set())
for (i, j) in enumerate(l):
	if a % j == 0 and j not in s:
		s.add(j)
		flag[i] = True
	else:
		b = j
		break
print(a, b)


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for r in range(len(x)):
		x1.append(int(x[r]))
	return x1

def finding_two_div(x):
	x.sort(reverse=True)
	x1 = x[0]
	for i in range(1, len(x)):
		if x1 % x[i] != 0 or x[i] == x1:
			return (x1, x[i])
	for i in range(len(x)):
		k = x.count(x[i])
		if k > 1:
			return (x1, x[i])
input()
(a, b) = finding_two_div(read_array())
print(a, b)


from collections import deque
from math import ceil
import sys
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
x = a[0]
s = set()
for i in a.copy():
	if x % i == 0 and (not i in s):
		a.remove(i)
		s.add(i)
y = a[0]
print(x, y)


n = int(input())
a = [int(x) for x in input().split()]
maxi = max(a)
removed = []
i = 0
while i < len(a):
	if maxi % a[i] == 0 and a[i] not in removed:
		removed.append(a[i])
		a.remove(a[i])
	else:
		i += 1
print(maxi, max(a))


num = int(input())
d = input().split()
list1 = []
for i in d:
	list1.append(int(i))
result1 = max(list1)
temp = [0] * (result1 + 1)
for i in range(1, result1 + 1, 1):
	if result1 % i == 0:
		temp[i] = 1
for i in list1:
	temp[i] += 1
result2 = 0
for i in range(len(temp)):
	if temp[i] != 2 and temp[i] > 0:
		result2 = i
print(result1, result2)


input()
a = list(map(int, map(int, input().split())))
b = max(a)
for d in range(1, b + 1):
	if b % d == 0:
		a.remove(d)
print(b, max(a))


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
m = max(l)
d = Counter(l)
v = 0
for (i, j) in d.items():
	if m % i == 0:
		d[i] -= 1
	if d[i] > 0 and i > v:
		v = i
print(m, v)


n = int(input())
task = list(map(int, input().split()))
y = max(task)
y_del = []
a = 1
b = y
while a < b:
	if y % a == 0:
		b = int(y / a)
		if b != a:
			y_del.append(a)
			y_del.append(b)
		else:
			y_del.append(a)
	a += 1
for i in y_del:
	task.remove(i)
x = max(task)
print(y, x)


a = int(input())
s = list(map(int, input().split()))
b = max(s)
s.remove(b)
g = 0
while g != b // 2:
	g += 1
	if b % g == 0:
		s.remove(g)
print(b, max(s))


(n, ls) = (int(input()), sorted(list(map(int, input().split()))))
a = ls.pop(-1)
for p in range(1, a):
	if p > a:
		break
	if a % p == 0:
		ls.remove(p)
print(a, ls[-1])


from collections import *
input()
d = Counter(map(int, input().split()))
m = max(d)
for i in range(1, m + 1):
	if m % i == 0:
		d[i] -= 1
print(m, max(d.elements()))


a = []

def printDivisors(n):
	i = 1
	while i <= n:
		if n % i == 0:
			a.append(i)
		i = i + 1
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l[-1]
printDivisors(m)
for i in a:
	for j in range(n):
		if l[j] == i:
			l[j] = -1
			break
l.sort()
print(m, l[-1])


input()
d = list(map(int, input().split()))
d.sort()
x = d[-1]
for t in set(d):
	if x % t == 0:
		d.remove(t)
y = d[-1]
print(x, y)


n = int(input())
d = input().split()
a = [0 for j in range(10 ** 4 + 1)]
for i in range(n):
	d[i] = int(d[i])
	a[d[i]] += 1
d.sort(reverse=True)
x = d[0]
for j in range(1, x + 1):
	if x % j == 0:
		a[j] -= 1
for l in range(10 ** 4 + 1):
	if a[l] == 1:
		y = l
print(x, y)


n = int(input())
a = list(map(int, input().split()))
x = max(a)
for k in range(1, x + 1):
	if x % k == 0:
		a.remove(k)
y = max(a)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(1, n + 1):
	i = n - i
	if a[i] == a[i - 1]:
		print(a[n - 1], a[i])
		exit()
	if a[n - 1] % a[i] != 0:
		print(a[n - 1], a[i])
		exit()


import sys
import math

def read_int():
	return int(input().strip())

def read_int_list():
	return list(map(int, input().strip().split()))

def read_string():
	return input().strip()

def read_string_list(delim=' '):
	return input().strip().split(delim)
n = read_int()
arr = read_int_list()
arr.sort()
a = arr[-1]
end = n - 2
if arr[end] == a:
	print(a, a)
	sys.exit()
while a % arr[end] == 0 and end > 0:
	temp = arr[end]
	end -= 1
	if arr[end] == temp:
		b = arr[end]
		print(a, b)
		sys.exit()
b = arr[end]
print(a, b)
sys.exit()


n = int(input())
a = list(map(int, input().split()))
maximum = max(a)
b = []
for i in range(0, n):
	if a[i] not in b:
		if maximum % a[i] == 0:
			b.append(a[i])
			a[i] = 0
smaximum = max(a)
print('{0} {1}'.format(maximum, smaximum))


import sys
import math

def lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	return int(num1 * num2 / den)
n = int(sys.stdin.readline().rstrip())
factors = list(map(int, sys.stdin.readline().split()))
unique = {}
numX = factors[0]
numY = 1
for num in factors:
	if num > numX:
		numX = num
	if num in unique:
		numY = lcm(numY, num)
		unique.pop(num)
	else:
		unique[num] = 1
for num in unique.keys():
	if unique[num]:
		if numX % num:
			numY = lcm(numY, num)
print(str(numX) + ' ' + str(numY))


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
y = a[n - 1]
nu = []
for i in range(1, y // 2 + 1):
	if y % i == 0:
		nu.append(i)
		nu.append(y // i)
k = 0
b += set(nu)
b.sort()
for i in range(n):
	if k >= len(b):
		break
	if a[i] == b[k]:
		a[i] = 0
		k += 1
a.sort()
x = max(a)
print(x, y)


n = int(input())
s = []
for d in input().split(' '):
	s.append(int(d))
maxv = max(s)
(s1, s2) = ([], [])
for d in s:
	if maxv % d == 0:
		if d not in s1:
			s1.append(d)
		else:
			s2.append(d)
	else:
		s2.append(d)
maxv2 = max(s2)
print(maxv, maxv2)


from collections import deque
input()
d1 = sorted(map(int, input().split()))
(a, d2) = (d1[-1], deque())
for i in range(len(d1)):
	if a % d1[i] != 0:
		d2.append(d1[i])
	elif i > 0 and d1[i] == d1[i - 1]:
		d2.append(d1[i])
print(a, d2.pop())


n = int(input())
d = list(map(int, input().split()))
x = max(d)
d_x = []
for di in d:
	if x % di == 0 and di not in d_x:
		d_x.append(di)
for d_xi in d_x:
	d.remove(d_xi)
y = max(d)
print(x, y)


input()
(A, B) = (set(), set())
for d in map(int, input().split()):
	if d in A:
		B.add(d)
	else:
		A.add(d)
x = max(A)
print(x, max(B | {d for d in A if x % d}))


n = int(input())
a = [int(x) for x in input().split()]
b = []
c = []
maxi = max(a)
for i in range(n):
	if maxi % a[i] == 0 and a[i] not in b:
		b.append(a[i])
	else:
		c.append(a[i])
print(maxi, max(c))


n = int(input())
m = list(map(int, input().split()))
m.sort()
a = m[n - 1]
i = n - 2
t = set()
t.add(a)
print(a, end=' ')
while i >= 0 and (not m[i] in t) and (a % m[i] == 0):
	t.add(m[i])
	i -= 1
b = m[i]
print(b)


from collections import Counter

def divisors(lst):
	maximum = max(lst)
	(c, q) = (Counter(lst), 1)
	for elem in lst:
		if elem > q and c[elem] == 2:
			q = elem
	for elem in lst:
		if elem > q and maximum % elem != 0:
			q = elem
	return (maximum, q)
n = int(input())
a = [int(i) for i in input().split()]
print(*divisors(a))


n = int(input())
nums = list(map(int, input().split()))
k = max(nums)
for i in range(1, k + 1):
	if k % i == 0:
		nums.remove(i)
g = max(nums)
print(k, g)


from __future__ import division, print_function
MOD = 998244353
mod = 10 ** 9 + 7

def prepare_factorial():
	fact = [1]
	for i in range(1, 100005):
		fact.append(fact[-1] * i % mod)
	ifact = [0] * 100005
	ifact[100004] = pow(fact[100004], mod - 2, mod)
	for i in range(100004, 0, -1):
		ifact[i - 1] = i * ifact[i] % mod
	return (fact, ifact)
import sys
from bisect import bisect_left, bisect_right, insort
from math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians
from heapq import heappop, heapify, heappush
from collections import Counter, defaultdict, deque

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, fact, ifact):
	t = fact[n] * (ifact[r] * ifact[n - r]) % mod % mod
	return t

def intarray():
	return map(int, sys.stdin.readline().strip().split())

def array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // GCD(x, y)

def get_xor(n):
	return [n, 1, n + 1, 0][n % 4]

def fast_expo(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a
			res %= MOD
			b -= 1
		else:
			a = a * a
			a %= MOD
			b >>= 1
	res %= MOD
	return res

def get_n(P):
	ans = (-1 + sqrt(1 + 8 * P)) // 2
	return ans

def finddivisor(m, d):
	for i in range(1, int(sqrt(m) + 1)):
		if m % i == 0:
			d[i] -= 1
			if i == m // i:
				continue
			else:
				d[m // i] -= 1

def solve():
	n = int(input())
	a = array()
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	m = max(a)
	finddivisor(m, d)
	maxi = 0
	for i in d.keys():
		if d[i] > 0:
			maxi = max(maxi, i)
	print(m, maxi)
	return

def main():
	T = 1
	while T:
		solve()
		T -= 1
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')
main()


n = int(input())
s = input().split()
a = []
for i in s:
	a.append(int(i))
b = []
m = max(a)
for i in range(len(a)):
	if a[i] != m:
		if m % a[i] == 0 and a[i] not in b:
			b.append(a[i])
			a[i] = -1
y = m
a.remove(m)
x = max(a)
print(x, y)


q = int(input())
l = list(map(int, input().split()))
a = max(l)
print(a, end=' ')
for i in range(1, a + 1):
	if a % i == 0 and i != -1:
		l[l.index(i)] = -1
print(max(l))


input()
c = list(map(int, input().split()))
b = max(c)
j = 1
while j * j <= b:
	if b % j == 0:
		c.remove(j)
		if b // j != j:
			c.remove(b // j)
	j += 1
print(b, max(c))


n = int(input())
l = list(map(int, input().split()))
l.sort()
y = l[-1]
i = n - 1
while i > 0:
	if l.count(l[i]) == 2:
		x = l[i]
		break
	elif y % l[i] != 0:
		x = l[i]
		break
	i -= 1
print(x, y)


n = int(input())
L = [int(d) for d in input().strip().split()]
x = max(L)
x_divisors = {}
y = 0
for d in L:
	if x % d != 0 or d in x_divisors:
		if d > y:
			y = d
	elif x % d == 0:
		x_divisors[d] = True
print(f'{x} {y}')


n = int(input())
a = [int(j) for j in input().split()]
a.sort()
x = []
y = []
ans1 = a[n - 1]
for i in range(1, ans1 + 1):
	if ans1 % i == 0:
		a.remove(i)
print(a[len(a) - 1], ans1)


import math
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
r = int(math.sqrt(nums[n - 1])) + 1
x = nums[n - 1]
arr = []
for i in range(1, r):
	if x % i == 0:
		if i ** 2 == x:
			arr.append(i)
		else:
			arr.append(i)
			arr.append(x // i)
for i in arr:
	nums.remove(i)
nums.sort()
l = len(nums)
if l == 0:
	y = x
else:
	y = nums[l - 1]
print(x, y)


from sys import stdin, stdout
from collections import Counter
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	y = max(a)
	x = 0
	d = Counter(a)
	for factor in range(1, y + 1):
		if y % factor == 0:
			d[factor] -= 1
	for (k, v) in d.items():
		if v > 0:
			x = max(x, k)
	print(x, y)


n = int(input())
m = list(map(int, input().split()))
m.sort()
a = m[n - 1]
i = n - 2
print(a, end=' ')
while i >= 0 and m[i] != m[i + 1] and (a % m[i] == 0):
	i -= 1
b = m[i]
print(b)


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
b = []
for i in range(len(a) - 1):
	if m % a[i] != 0 or a[i] == a[i + 1]:
		b.append(a[i])
for i in range(len(a) - 1):
	for j in range(len(b)):
		if a[i] % b[j] != 0:
			break
		if j == len(b) - 1:
			print(a[i], m)
			exit()


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
n = int(input())
l = L()
l.sort()
k = l[-1]
i = 1
while i <= math.sqrt(k):
	if k % i == 0:
		l.remove(i)
		if i != k // i:
			l.remove(k // i)
	i += 1
l.sort()
print(k, l[-1])


n = int(input())
l = list(map(int, input().split()))
x = max(l)
c = 1
while c <= x:
	if x % c == 0:
		l.remove(c)
	c += 1
y = max(l)
print(x, y)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
div = []
for i in l:
	div.append(i)
check = []
for i in l:
	if i not in check and m % i == 0:
		div.remove(i)
		check.append(i)
print(max(div), max(l))


class CountingDict(dict):

	def __missing__(self, key):
		return 0
slen = input()
divs = [int(i) for i in input().split(' ')]
sorted_divs = sorted(divs, reverse=True)
sorted_divs_copy = set(sorted_divs)
y = sorted_divs[0]
for div in sorted_divs_copy:
	if y % div == 0:
		sorted_divs.remove(div)
x = sorted_divs[0]
print(str(x) + ' ' + str(y))


n = int(input())
arr = sorted([int(x) for x in input().split()])
x = max(arr)
for i in range(1, x + 1):
	if x % i == 0:
		arr.remove(i)
y = max(arr)
print(x, y)


n = int(input())
d = list(map(int, input().split()))
r1 = max(d)
d.remove(r1)
r2 = max(d)
if r1 == r2:
	print(str(r1) + ' ' + str(r2))
else:
	p = []
	q = []
	for i in d:
		if i in p:
			q.append(i)
		else:
			p.append(i)
	p.remove(1)
	for i in range(len(p)):
		if r1 % p[i] != 0:
			q.append(p[i])
	r2 = max(q)
	print(str(r1) + ' ' + str(r2))


n = int(input())
numbers = list(map(int, input().split()))
numbers.sort(reverse=True)
num1 = numbers[0]
div_num1 = set()
for val in numbers:
	if num1 % val == 0:
		div_num1.add(val)
for val in div_num1:
	numbers.remove(val)
if len(numbers) == 0:
	num2 = num1
else:
	numbers.sort(reverse=True)
	num2 = numbers[0]
print(num1, num2)


n = int(input())
a = list(map(int, input().split()))
m1 = max(a)
d = {}
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in d:
	if m1 % i == 0:
		d[i] -= 1
b = []
for i in d:
	if d[i] > 0:
		b.append(i)
print(m1, max(b))


import math

def fac(n):
	w = []
	for i in range(1, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if n / i == i:
				w.append(i)
			else:
				w.append(i)
				w.append(n // i)
	return w
t = int(input())
l = list(map(int, input().split()))
k = sorted(l)
r = 0
for i in range(t):
	for j in range(i + 1, t):
		q = fac(l[i])
		a = fac(l[j])
		ne = q + a
		ne.sort()
		if ne == k:
			print(l[i], l[j])
			r = 1
			break
	if r == 1:
		break


(n, a) = (int(input()), list(sorted(map(int, input().split()), reverse=True)))
x = a[0]
for i in range(1, n):
	if x % a[i] != 0 or a[i] == a[i - 1]:
		y = a[i]
		break
print(x, y)


n = int(input())
l = input()
l = sorted([int(x) for x in l.split()])
(no1, prev, no2) = (l[-1], l[-1], 0)
for i in range(n - 2, -1, -1):
	if no1 % l[i] or (not no1 % l[i] and l[i] == prev):
		no2 = l[i]
		break
	prev = l[i]
print(str(no1) + ' ' + str(no2))


import sys
inn = lambda : input().strip()
n = int(inn())
shuffle = list(map(int, inn().split(' ')))
shuffle.sort()
x = max(shuffle)
divisor_x = [d for d in range(1, x + 1) if x % d == 0]
i = 0
isDivisorOfX = [False] * n
for d in divisor_x:
	while shuffle[i] != d:
		i += 1
	isDivisorOfX[i] = True
	i += 1
y = [i for (i, isX) in enumerate(isDivisorOfX) if not isX]
y = shuffle[y[-1]]
print(f'{x} {y}')


n = int(input())
l = list(map(int, input().split(' ')))
l.sort(reverse=True)
b = [False] * n
(a, s) = (l[0], set())
for (i, j) in enumerate(l):
	if a % j == 0 and j not in s:
		s.add(j)
		b[i] = True
ans = 0
for (c, d) in enumerate(b):
	if d is False:
		ans = l[c]
		break
print(a, ans)


n = int(input())
a = list(map(int, input().split()))
num = {}
(x, y) = (max(a), [])
for i in set(a):
	if x % i == 0:
		a.remove(i)
print(x, max(a))


n = int(input())
q = list(map(int, input().split()))
x = max(q)
print(x, end=' ')
lst = []
for i in range(1, x + 1):
	if x % i == 0:
		q.remove(i)
print(max(q), end=' ')


n = int(input())
a = list(map(int, input().split()))
p = max(a)
d = []
for i in range(n):
	if p % a[i] != 0:
		d.append(a[i])
w = []
for i in range(n):
	if a.count(a[i]) == 2:
		w.append(a[i])
if len(d) == 0:
	d.append(max(w))
print(p, max(d))


from sys import stdin, stdout
from collections import defaultdict
import math
I = stdin.readline
P = stdout.write
n = int(I())
arr = [int(x) for x in I().split()]
arr.sort(reverse=True)
a = arr[0]
freq = [0 for i in range(a + 1)]
arr2 = []
for i in range(0, n):
	if a % arr[i] != 0:
		arr2.append(arr[i])
	elif freq[arr[i]] == 0:
		freq[arr[i]] += 1
	else:
		arr2.append(arr[i])
b = max(arr2)
print(a, b)


n = int(input())
d = [int(x) for x in input().split()]
dic = {}
for x in d:
	dic[x] = dic.get(x, 0) + 1
x = max(d)
for i in range(1, x + 1):
	if x % i == 0:
		dic[i] -= 1
y = max([k for (k, v) in dic.items() if v > 0])
print(x, y)


n = int(input())
a = list(map(int, input().split()))
f = max(a)
m = {}
b = a.copy()
arr = []
for x in a:
	if x not in m:
		if f % x == 0:
			m[x] = 1
			b.remove(x)
print(f, max(b))


n = int(input())
a = list(map(int, input().split()))
max = a[0]
for i in range(1, n):
	if a[i] > max:
		max = a[i]
x = max
L = list()
i = 0
while i < n:
	h = a[i]
	for j in range(i + 1, n):
		if a[j] == h:
			L.append(h)
	i += 1
ma = L[0]
for j in range(len(L)):
	if L[j] > ma:
		ma = L[j]
H = list()
for i in range(n):
	if x % a[i] != 0:
		H.append(a[i])
if H == []:
	y = ma
else:
	may = H[0]
	for j in range(1, len(H)):
		if H[j] > may:
			may = H[j]
	y = may
print(x, y)


n = int(input())
d = [int(x) for x in input().split()]
a = [0] * 10001
for x in d:
	a[x] += 1
single = []
double = []
for i in range(10001):
	if a[i] == 1:
		single.append(i)
	elif a[i] == 2:
		double.append(i)
lens = len(single)
lend = len(double)
if lens == 0:
	print(double[lend - 1], double[lend - 1])
else:
	maxi = single[lens - 1]
	print(maxi, end=' ')
	single.pop(lens - 1)
	lens -= 1
	for i in range(lens - 1, -1, -1):
		if maxi % single[i] == 0:
			single.pop(i)
	if len(single) == 0:
		print(double[lend - 1])
	else:
		print(max(single))


n = int(input())
a = [int(i) for i in input().split()]
b = []
k = max(a)
i = 0
while i < len(a):
	if k % a[i] == 0 and a[i] not in b:
		b.append(a[i])
		a.remove(a[i])
		i -= 1
	i += 1
k1 = max(a)
print(k, k1)


from collections import Counter
counter = Counter()
n = int(input())
arr = list(map(int, input().split()))
for num in arr:
	counter[num] += 1
keys = sorted(counter.keys(), reverse=True)
a = keys[0]
b = 1
for key in keys:
	if a % key == 0:
		counter[key] -= 1
	if counter[key] == 1:
		if b % key != 0:
			b *= key
print(a, end=' ')
print(b)


n = int(input())
li = [int(x) for x in input().split()]
li.sort()
m = li[n - 1]
for i in range(1, m // 2 + 1):
	if m % i == 0:
		li.remove(i)
print(m, end=' ')
li.remove(m)
print(max(li))


from fractions import gcd as gcd

def lcm(a, b):
	return a * b // gcd(a, b)

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	cnt = dict()
	for i in a:
		if i not in cnt:
			cnt[i] = 1
		else:
			cnt[i] += 1
	(X, Y) = (1, 1)
	(cnt2, cnt1) = ([], [])
	(x, y) = ([], [])
	for i in a:
		if cnt[i] == 2:
			cnt2.append(i)
		else:
			cnt1.append(i)
	for i in cnt2:
		X = lcm(X, i)
		Y = lcm(Y, i)
		x.append(i)
		y.append(i)
	for i in cnt1:
		ok = True
		for j in x:
			if lcm(i, j) not in cnt1:
				ok = False
				break
		if ok:
			X = lcm(X, i)
			x.append(i)
		else:
			Y = lcm(Y, i)
			y.append(i)
	print(X, Y)
main()


n = int(input())
arr = sorted([int(x) for x in input().split(' ')])
x = arr[-1]
xarr = []
yarr = []
for a in arr:
	if x % a == 0:
		if a not in xarr:
			xarr.append(a)
		else:
			yarr.append(a)
	elif a not in yarr:
		yarr.append(a)
	else:
		xarr.append(a)
y = yarr[-1]
print(x, y)


n = int(input())
data = sorted([int(x) for x in input().split()])[::-1]
(a, b) = (data[0], 1)
for i in range(n):
	if a % data[i] != 0 or data.count(data[i]) == 2:
		b = data[i]
		break
print(a, b)


n = int(input())
m = [int(i) for i in input().split()]
m = sorted(m)
doubled = []
a = max(m)
for i in range(len(m) - 1):
	if not a % m[i] and m[i] != m[i + 1]:
		m[i] = 1
m.remove(max(m))
print(a, max(m))


n = int(input())
arr = sorted([int(p) for p in input().split()], reverse=True)
div1 = set()
div2 = set()
for i in range(len(arr)):
	if arr[i] not in div1 and arr[0] % arr[i] == 0:
		div1.add(arr[i])
	else:
		div2.add(arr[i])
print(max(div1), max(div2))


N = int(input())
arr = [int(i) for i in input().split()]
a = max(arr)
arr.remove(a)
b = max(arr)
print(a, end=' ')
if a == b:
	print(b)
else:
	r = len(arr)
	for i in range(r):
		b = max(arr)
		arr.remove(b)
		t = max(arr)
		if b == t:
			print(b)
			break
		elif a % b != 0:
			print(b)
			break
	else:
		print(1)


n = int(input())
a = [int(q) for q in input().strip().split()]
a.sort()
a = a[::-1]
t = 0
for k in range(1, n):
	if int(a[0]) % int(a[k]) != 0:
		print(str(a[0]) + ' ' + str(a[k]))
		t = 1
		break
if t == 0:
	for k in range(n - 1):
		if a[k] == a[k + 1]:
			print(str(a[0]) + ' ' + str(a[k]))
			break


import math
n = int(input())
L = [int(x) for x in input().split()]
D = {}
for i in L:
	if i in D:
		D[i] += 1
	else:
		D[i] = 1
x = max(L)
for i in range(1, int(math.sqrt(x)) + 1):
	if x % i == 0:
		if i * i != x:
			D[i] -= 1
			D[x // i] -= 1
		else:
			D[i] -= 1
best = 0
for i in D:
	if D[i] > 0:
		best = max(best, i)
print(x, best)


n = int(input())
i = 0
letters = input()
letters = letters.split()
for i in range(len(letters)):
	letters[i] = int(letters[i])
letters.sort()
j = n - 1
string = ''
while j > 0:
	if letters[j - 1] == letters[j] or letters[n - 1] % letters[j] != 0:
		string += str(letters[n - 1]) + ' ' + str(letters[j])
		break
	j -= 1
print(string)


t = int(input())
row = input().split()
for i in range(t):
	row[i] = int(row[i])
row.sort()
n1 = row[t - 1]
i = t - 1
if row[i] == n1:
	n2 = row[i]
while i >= 1:
	if n1 % row[i] != 0:
		n2 = row[i]
		break
	elif row[i - 1] == row[i]:
		n2 = row[i]
		break
	else:
		i = i - 1
print(n1, n2)


def gcd(a: int, b: int):
	while b:
		(a, b) = (b, a % b)
	return a
n = int(input())
ar = sorted(list(map(int, input().split())))
was = set()
(a, b) = (1, 1)
for i in range(n):
	if ar[i] in was:
		if b * (ar[i] // gcd(ar[i], b)) in ar:
			b *= ar[i] // gcd(ar[i], b)
		else:
			a *= ar[i] // gcd(ar[i], a)
	elif a * (ar[i] // gcd(ar[i], a)) in ar:
		a *= ar[i] // gcd(ar[i], a)
	else:
		b *= ar[i] // gcd(ar[i], b)
	was.add(ar[i])
print(a, b)


a = int(input())
b = [int(x) for x in input().split()]
b.sort(key=lambda x: -x)
x = b[0]
for m in range(1, x + 1):
	if x % m == 0:
		b.remove(m)
print(x, b[0])


from copy import deepcopy
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
x = 0
j = 0
y = 0
b = []
x = a[n - 1]
b = deepcopy(a)
for i in range(n):
	if x % a[i] == 0:
		a[i] = 0
	else:
		j = i
if sum(a) == 0:
	y = b[n - 2]
else:
	y = b[j]
if x % y == 0:
	for i in range(n - 1):
		if b[i] == b[i + 1]:
			j = i
	print(x)
	print(b[j])
else:
	print(x)
	print(y)


n = int(input())
delimiters = list(map(int, input().split()))
delimiters.sort()
used_nums = dict()
result = []
for num in delimiters:
	if num not in used_nums and delimiters[-1] % num == 0:
		used_nums[num] = True
		continue
	result.append(num)
print(delimiters[-1], max(result))


n = int(input())
array = [int(i) for i in input().split()]
first_ans = max(array)
for i in range(1, first_ans + 1):
	if first_ans % i == 0:
		if first_ans in array:
			array.remove(i)
print(first_ans, max(array))


n = int(input())
arr = list(map(int, input().split()))
temp = max(arr)
for i in range(1, temp + 1):
	if temp % i == 0:
		arr.remove(i)
print(temp, max(arr))


n = int(input())

def fun(p):
	m = max(p)
	t = []
	for i in p:
		if m % i != 0:
			t.append(i)
	if t != []:
		y = max(t)
	else:
		for i in p:
			if p.count(i) == 2:
				t.append(i)
		y = max(t)
	print(m, y)
p = [int(x) for x in input().split()]
fun(p)


n = int(input())
s = sorted(list(map(int, input().split())))[::-1]
for i in range(n - 1):
	if s[0] % s[i] != 0:
		print(s[0], s[i])
		exit()
	if s[i] == s[i + 1]:
		print(s[0], s[i])
		exit()


def fact(x):
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			if x // i == i:
				li1.append(i)
			else:
				li1.append(i)
				li1.append(x // i)
a = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
x = li[0]
li1 = []
fact(x)
li1.sort(reverse=True)
for i in range(len(li1)):
	if li1[i] != li[i]:
		print(x, li[i])
		exit()
print(x, li[i + 1])


n = int(input())
a = list(map(int, input().split()))
if a == [1, 1]:
	print(1, 1)
	exit(0)
a = sorted(a)
b = a[-1]
x = 1
for i in range(n - 2, -1, -1):
	if a[i] == a[i + 1] or b % a[i] != 0:
		x = a[i]
		break
print(b, x)


q = int(input())
ar = list(map(int, input().split()))
a = max(ar)
max = a
ar.sort(reverse=True)
for j in ar:
	if max % j != 0 and ar.count(j) == 1:
		break
	elif max % j == 0 and ar.count(j) == 2:
		break
print(str(a) + ' ' + str(j))


input()
l = sorted(list(map(int, input().split())))
s = set()
if l[-1] == l[-2]:
	print(l[-1], l[-1])
else:
	for i in l[-2::-1]:
		if l[-1] % i == 0 and i not in s:
			s.add(i)
		else:
			break
	print(l[-1], i)


from collections import Counter as co
I = lambda : map(int, input().split())
n = int(input())
a = co(I())
y = 1
b = sorted(list(a.keys()))
x = b[-1]
for i in range(1, x + 1):
	if x % i == 0:
		a[i] -= 1
for i in b[::-1]:
	if a[i] == 1:
		y = i
		break
print(x, y)


n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
maxx = a[0]
maxy = 1
dup = 1
for num in a:
	if num == dup:
		print(maxx, num)
		break
	if maxx % num != 0:
		print(maxx, num)
		break
	else:
		dup = num


n = int(input())
ls = sorted(list(map(int, input().split())))
if ls[-1] == ls[-2]:
	print(ls[-1], ls[-1])
else:
	n1 = ls[-1]
	n2 = 1
	for i in range(n - 2, -1, -1):
		if n1 % ls[i] or ls.count(ls[i]) == 2:
			n2 = ls[i]
			break
	print(n1, n2)


n = int(input())
d = input()
d = [int(i) for i in d.split(' ')]
x = max(d)
y = 1
d.remove(x)
while max(d) != 1:
	if x % max(d) != 0:
		y = max(d)
		break
	elif d.count(max(d)) == 2 or max(d) == x:
		y = max(d)
		break
	else:
		d.remove(max(d))
print(x, y)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def findlcm(arr, n):
	ans = arr[0]
	for i in range(len(arr)):
		ans = arr[i] * ans / gcd(arr[i], ans)
	return int(ans)
n = int(input())
a = [int(i) for i in input().split()]
b = sorted(set(a), reverse=True)
x = b[0]
y = [i for i in b if x % i != 0]
if len(y) == 0:
	k = 1
	c = [int(i) for i in b if a.count(i) == 2]
	print(x, findlcm(c, len(c)))
else:
	print(x, y[0])


def f(l):
	l.sort(reverse=True)
	x = l[0]
	n = len(l)
	for i in range(1, n):
		if x % l[i] > 0 or l[i] == l[i - 1]:
			return [x, l[i]]
_ = int(input())
l = list(map(int, input().split()))
print(*f(l))


def divisors(num):
	ret = list()
	for j in range(1, num + 1):
		if num % j == 0:
			ret.append(j)
	return ret
n = int(input())
x = input().split()
numbers = list(map(int, x))
number1 = max(numbers)
div = divisors(number1)
for j in range(len(div)):
	numbers.remove(div[j])
number2 = max(numbers)
print(number1, number2)


q = int(input())
s = input()
s = list(map(int, s.split(' ')))
m = max(s)
l = []
for i in range(len(s)):
	if m % s[i] == 0:
		if s[i] not in l:
			l.append(s[i])
			s[i] = 0
print(m, end=' ')
m = max(s)
print(m)


x = int(input())
arr2 = []
arr3 = []
arr1 = [int(x) for x in input().split()]
maxelement = max(arr1)
idx = 0
while idx < x:
	if maxelement % arr1[idx] == 0 and arr1[idx] not in arr2:
		arr2.append(arr1[idx])
	else:
		arr3.append(arr1[idx])
	idx += 1
print(maxelement, max(arr3))


q = int(input())
d = list(map(int, input().split()))
fi = max(d)
ne = []
for i in range(1, fi + 1):
	if fi % i == 0:
		d.remove(i)
sec = max(d)
print(fi, sec)


n = int(input())
ar = list(map(int, input().split()))
br = list(set(ar))
p = max(ar)
for i in br:
	if p % i == 0:
		ar.remove(i)
q = max(ar)
print(p, q)


int(input())
a = [int(x) for x in input().split()]
m = max(a)
for i in range(1, m + 1):
	if m % i == 0:
		a.remove(i)
print(m, max(a))


n = int(input())
a = list(map(int, input().split()))
a.sort()
mx = a[len(a) - 1]
mx1 = 0
for i in range(n - 1):
	if a[i] == mx:
		mx1 = mx
	if mx % a[i] or a[i] == a[i + 1]:
		mx1 = max(mx1, a[i])
print(mx, max(1, mx1))


q = int(input())
i = q - 1
i = 1
x = input()
x = [int(i) for i in x.split()]
x.sort()
num1 = x[q - 1]
while num1 % x[q - i] == 0 and x.count(x[q - i]) != 2:
	x.pop(q - i)
	i += 1
print(num1, x[q - i])


n = input()
lst = [*map(int, input().split())]
a = max(lst)
print(a, max((ele for ele in lst if a % ele or lst.count(ele) > 1)))


n = int(input())
k = input()
k = [int(s) for s in k.split(' ')]
result = {}
for i in range(len(k)):
	result[k[i]] = result[k[i]] + 1 if result.get(k[i]) else 1
maxi = max(k)
for i in result:
	if maxi % i == 0:
		result[i] = result[i] - 1
result1 = []
for i in result:
	if result[i] != 0:
		result1.append(i)
maxi1 = max(result1)
print(maxi, maxi1)


a = int(input())
b = [int(x) for x in input().strip().split(' ')]
b.sort()
k = b[-1]
print(k, end=' ')
c = []
for x in b:
	if k % x != 0:
		c.append(x)
if len(c) > 0:
	print(c[-1])
else:
	t = 0
	x = len(b) - 1
	while x >= 0:
		if t == b[x]:
			break
		t = b[x]
		x -= 1
	print(t)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
x = arr[-1]
yDiv = []
for i in range(n):
	if x % arr[i] != 0:
		yDiv.append(arr[i])
if yDiv != []:
	yDiv.sort()
	y = yDiv[-1]
else:
	c = Counter(arr)
	flag = dict()
	for items in set(arr):
		flag[items] = 0
	for i in range(n):
		if x % arr[i] == 0 and flag[arr[i]] == 0:
			c[arr[i]] -= 1
			flag[arr[i]] = 1
	for keys in c:
		if c[keys] > 0:
			yDiv.append(keys)
	yDiv.sort()
	y = yDiv[-1]
print(x, y)


n = int(input())
divs = list(map(int, input().split()))
a = max(*divs)
b = 1
for x in divs:
	if divs.count(x) == 2 or a % x != 0:
		b = max(b, x)
print(a, b)


n = int(input())
l = list(map(int, input().split()))
l2 = []
x = max(l)
max2 = 0
ma = 0
for i in l:
	if x % i != 0:
		if ma < i:
			ma = i
	elif ma == 0:
		if i not in l2:
			l2.append(i)
		elif i > max2:
			max2 = i
ma = max2 if ma == 0 else ma
print('{} {}'.format(x, ma))


import math
n = int(input())
f = []
l = list(map(int, input().split()))
x = max(l)
p = x
for i in range(len(l)):
	if p % l[i] == 0:
		if l[i] not in f:
			f.append(l[i])
for i in f:
	l.remove(i)
y = max(l)
print(x, y)


import math
n = int(input())
array = list(map(int, input().strip().split()))
d = dict()
for i in range(len(array)):
	if array[i] in d.keys():
		d[array[i]] += 1
	else:
		d[array[i]] = 1
x = max(array)

def divisors(numb):
	div = set()
	for i in range(1, int(math.sqrt(numb) + 1)):
		if numb % i == 0:
			div.add(i)
			div.add(numb // i)
	return div
max_div = divisors(x)

def find():
	curr = 0
	for i in range(len(array)):
		if not array[i] in max_div:
			if array[i] > curr:
				curr = array[i]
		elif d[array[i]] == 2:
			if array[i] > curr:
				curr = array[i]
	return curr
y = find()
print(*[x, y])


n = int(input())
a = list(map(int, input().split()))
x = max(a)
s = set()
i = 0
while i < len(a):
	if x % a[i] == 0:
		t = len(s)
		s.add(a[i])
		if len(s) > t:
			a.pop(i)
		else:
			i += 1
	else:
		i += 1
print(x, max(a))


import operator
n = int(input())
div = list(map(int, input().split(' ')))
y = max(div)
for i in range(1, y + 1):
	if y % i == 0:
		div.remove(i)
x = max(div)
print(x, y)


def divisors(n):
	lst1 = []
	for i in range(1, n + 1):
		if n % i == 0:
			lst1.append(i)
	return lst1
q = int(input())
lst = list(map(int, input().split()))
lst.sort()
max1 = max(lst)
lst4 = divisors(lst[len(lst) - 1])
for i in lst4:
	lst.remove(i)
from math import gcd
lcm = lst[0]
for i in lst:
	lcm = int(lcm * i / gcd(lcm, i))
print(lcm, max1)


n = int(input())
num = list(map(int, input().split()))
mnum = max(num)
s = []
s.append(mnum)
s.append(1)
x = len(num)
for j in range(x):
	if mnum % num[j] == 0 and num[j] != 1 and (num[j] != mnum):
		if s.count(num[j]) < 1:
			s.append(num[j])
			num[j] = 0
num.remove(mnum)
print(max(s), max(num))


n = int(input())
list = list(map(int, input().split()))
x = max(list)
y = 0
for elem in list:
	if list.count(elem) == 2 and elem > y:
		y = elem
for elem in list:
	if elem > y and elem % y == 0 and (x % elem != 0):
		y = elem
print(x, y)


n = int(input())
alist = [int(i) for i in input().split()]
alist.sort()
x = alist[-1]
if x == alist[-2]:
	ans = str(x) + ' ' + str(x)
	print(ans)
	exit(0)
for i in range(n - 2, -1, -1):
	y = alist[i]
	if x % y != 0:
		ans = str(x) + ' ' + str(y)
		print(ans)
		break
	elif y == alist[i - 1]:
		ans = str(x) + ' ' + str(y)
		print(ans)
		break


TN = 1

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	l = list(sorted(l, reverse=True))
	x = 0
	for i in l:
		if l[0] % i != 0:
			x = i
			break
	if x == 0:
		s = list(sorted(set(l), reverse=True))
		for i in s:
			if l.count(i) > 1:
				x = i
				break
	print(l[0], x)
while TN != 0:
	solution()
	TN -= 1


from collections import defaultdict as dc
n = int(input())
a = [int(i) for i in input().split()]
p = max(a)
l = []
x = []
y = []
m = dc(int)
r = []
for i in range(n):
	m[a[i]] += 1
for i in range(n):
	if p % a[i] == 0:
		l.append(a[i])
		if m[a[i]] > 1:
			r.append(a[i])
	else:
		r.append(a[i])
print(max(l), max(r))


n = int(input())
s = list(map(int, input().split()))
m = max(s)
for i in range(m, 0, -1):
	if m % i == 0:
		del s[s.index(i)]
print(m, max(s))


num = int(input())
lis = input()
lis = list(map(int, lis.split()))
a1 = max(lis)
lis.remove(a1)
for i in range(1, a1):
	if a1 % i == 0:
		lis.remove(i)
print(a1, max(lis))


input()
l = list(map(int, input().split()))
m = max(l)
(ls, l2) = ([], [])
for i in l:
	if m % i == 0:
		ls.append(i)
	else:
		l2.append(i)
ls = list(set(ls))
l3 = list(set([x for x in l if l.count(x) > 1]))
l2 = l2 + l3
m2 = max(l2)
print(m, m2)


from functools import reduce

def factors(n):
	k = set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5 + 1)) if n % i == 0)))
	k = sorted(k)
	return set(k)
n = int(input())
k = [int(i) for i in input().split()]
a = max(k)
k1 = factors(a)
for i in k1:
	if i in k:
		k.remove(i)
print(a, max(k))


N = int(input())
L = list(map(int, input().split()))
a = max(L)
L.remove(a)
for i in range(1, a):
	if a % i == 0:
		L.remove(i)
print(a, max(L))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
a1 = l[0]
for i in range(1, n):
	if a1 % l[i] != 0 or l.count(l[i]) > 1:
		print(a1, l[i])
		exit()
print(a1, 1)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)
x = l[0]
for i in range(1, x + 1):
	if x % i == 0:
		l.remove(i)
print(x, max(l))


a = int(input())
b = list((int(x) for x in input().split()))
p = max(b)
for i in set(b):
	if p % i == 0:
		b.remove(i)
q = max(b)
print(p, q)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
(s, l) = (set(), [])
for di in d:
	if x % di == 0 and di not in s:
		s.add(di)
	else:
		l.append(di)
y = max(l)
print(x, y)


n = int(input())
nums = [int(x) for x in input().split()]
ma = max(nums)
re = [False] * (ma + 1)
rest = []
for nu in nums:
	if ma % nu == 0 and (not re[nu]):
		re[nu] = True
	else:
		rest.append(nu)
print(ma, max(rest))


n = int(input())
a = list(map(int, input().split(' ')))
b = []
m = max(a)
for i in range(n - 1, -1, -1):
	if m % a[i] == 0 and (not a[i] in b):
		b.append(a.pop(i))
print(m, max(a))


n = int(input())
A = [int(x) for x in input().split()]
x = max(A)
for i in range(1, x + 1):
	if x % i == 0:
		A.remove(i)
y = max(A)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
y = a[0]
ind = 0
for i in range(n - 1):
	if a[i] == a[i + 1]:
		y = a[i]
		ind = 0
for i in range(ind, n):
	if x % a[i] != 0:
		y = a[i]
print(x, y)


n = int(input())
a = []
a = [int(x) for x in input().split()]
a.sort()
x = a[n - 1]
b = []
c = []
fq = [0] * (10000 + 2)
for i in range(n):
	fq[a[i]] += 1
for i in range(n):
	if x % a[i] == 0 and a[i] not in c:
		c.append(a[i])
b = set(a) - set(c)
b = list(b)
for i in range(10000 + 2):
	if fq[i] == 2:
		b.append(i)
b.sort()
l = len(b)
y = b[l - 1]
print(x, y)


N = int(input())
a = sorted(list((int(x) for x in input().split())))
b = list()
x = a[-1]
use = [0] * (x + 1)
for i in range(1, x + 1):
	if x % i == 0:
		use[i] = 1
for ele in a:
	if x % ele == 0 and use[ele] == 1:
		b.append(1)
		use[ele] = 0
	else:
		b.append(ele)
y = sorted(b)[-1]
print(x, y, sep=' ')


def factors(x):
	result = []
	i = 1
	while i * i <= x:
		if x % i == 0:
			result.append(i)
			if x / i != i:
				result.append(int(x / i))
		i += 1
	return result
n = int(input())
a = list(map(int, input().split()))
x = max(a)
divx = factors(x)
for i in range(len(divx)):
	a.remove(divx[i])
print(x, max(a))


def deliteli():
	q = int(input())
	f = list(map(int, input().split()))
	m = max(f)
	s = set()
	i = 0
	while i != len(f):
		if m % f[i] == 0 and f[i] not in s:
			s.add(f[i])
			del f[i]
			i -= 1
		i += 1
	print(m, max(f))
	exit()
print(deliteli())


n = int(input())
nums = []
nums = list(map(int, input().split()))
nums.sort(reverse=True)
freq = {}
for i in nums:
	if i in freq:
		freq[i] += 1
	else:
		freq[i] = 1
x = nums[0]
for i in range(1, n):
	if x % nums[i] == 0 and freq[nums[i]] > 1:
		y = nums[i]
		break
	if x % nums[i] != 0:
		y = nums[i]
		break
print(x, y)


def findTheThing(a, n):
	if n == 2:
		print(1, 1)
	else:
		a.sort()
		ans1 = a[-1]
		for i in range(n - 2, -1, -1):
			if a.count(a[i]) == 2:
				ans2 = a[i]
				break
			if ans1 % a[i] != 0:
				ans2 = a[i]
				break
		print(ans1, ans2)
n = int(input())
a = list(map(int, input().split()))
findTheThing(a, n)


n = int(input())
divisors = list(map(int, input().split()))
x = max(divisors)
div_x = set()
for i in range(n):
	if divisors[i] not in div_x:
		if x % divisors[i] == 0:
			div_x.add(divisors[i])
			divisors[i] = 0
y = max(divisors)
print(x, y)


x = int(input())
l = sorted(list(map(int, input().split())))
maxs = max(l)
for i in range(x - 1):
	if maxs % l[i] == 0:
		if l[i] != l[i + 1]:
			l[i] = 0
l[-1] = 0
print(maxs, max(l))


n = int(input())
a = list(map(int, input().split()))
p = max(a)
a = sorted(a)
for i in range(1, int(p ** 0.5) + 1):
	if p % i == 0:
		if p // i != i:
			a.remove(i)
			a.remove(p // i)
		else:
			a.remove(i)
print(p, max(a))


n = int(input())
a = sorted(list(map(int, input().split())))
for i in range(n - 2, -1, -1):
	if a[-1] % a[i] != 0:
		break
	elif a[i] == a[i + 1]:
		break
print(a[-1], a[i])


n = int(input())
l = list(map(int, input().split()))
r = max(l)
k = []
for j in range(1, int(r ** 0.5) + 1):
	if r % j == 0:
		if r // j == j:
			k.append(j)
			l.remove(j)
		else:
			k.append(j)
			l.remove(j)
			k.append(r // j)
			l.remove(r // j)
print(r, max(l))


n = int(input())
nums = [int(c) for c in input().split(' ')]
occur = {}
for num in nums:
	if num not in occur:
		occur[num] = 0
	occur[num] += 1
gcd = 1
for num in occur:
	if occur[num] == 2:
		gcd = max(gcd, num)
b = max(nums)
for num in occur:
	if b % num == 0:
		occur[num] -= 1
a = 1
for num in occur:
	if occur[num] == 1:
		a = max(a, num)
print(a, b)


import math
n = int(input())
a = list(map(int, input().split(' ')))
m = max(a)
d = []
for i in range(1, m + 1):
	if m % i == 0:
		d.append(i)
a.sort()
d.sort()
for i in range(len(d)):
	a.remove(d[i])
print(m, max(a))


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
n = int(input())
l = input().split()
m = [int(i) for i in l]
mx = max(m)
mxfactors = factors(mx)
for i in mxfactors:
	m.remove(i)
nx = max(m)
print(mx, ' ', nx)


t = int(input())
lis = list(map(int, input().split()))
maxnum = max(lis)
lis.remove(maxnum)
for x in range(1, maxnum // 2 + 1):
	if maxnum % x == 0:
		lis.remove(x)
maxnum2 = max(lis)
print('{} {}'.format(maxnum, maxnum2))


n = int(input())
a = list(map(int, input().split()))
n1 = max(a)
b = a.copy()
for i in range(1, n1 + 1):
	if n1 % i == 0:
		b.remove(i)
n2 = max(b)
print(n1, '', n2)


n = int(input())
d = [int(x) for x in input().split()]
d.sort()
x = d[n - 1]
ar = []
for num in range(1, x + 1):
	if x % num == 0:
		ar.append(num)
for each in ar:
	d.remove(each)
y = d[len(d) - 1]
print(x, y)


t = int(input())
aray = list(map(int, input().split(' ')))
maximum = max(aray)
x = []
for i in range(t):
	if maximum % aray[i] == 0:
		if aray[i] not in x:
			x.append(aray[i])
			aray[i] = -1
maximum2 = max(aray)
print(str(maximum) + ' ' + str(maximum2))


n = int(input())
l = list(map(int, input().split()))
a = []
b = []
c = []
l.sort()
if l[0] == 1 and l[1] == 1 and (n == 2):
	print('1 1')
else:
	for i in range(1, n, 1):
		if l[i] == l[i - 1]:
			a.append(l[i])
			b.append(l[i - 1])
			i += 1
		else:
			c.append(l[i])
	c.sort()
	v = c[len(c) - 1]
	for i in range(len(c)):
		if v % c[i] == 0:
			a.append(c[i])
		else:
			b.append(c[i])
	print(a[len(a) - 1], b[len(b) - 1], sep=' ')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 1000000007
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	x = a[-1]
	k = 0
	pc = 1
	for i in range(n - 2, -1, -1):
		if x % a[i] != 0 or pc == x // a[i]:
			k = 1
			y = a[i]
			break
		else:
			pc = x // a[i]
	if k == 0:
		y = a[-2]
	print(x, y)


import math

def finddivisors(num):
	divisors = []
	i = 1
	while i ** 2 <= num:
		if math.sqrt(num) == i:
			divisors.append(i)
		elif num % i == 0:
			divisors.append(i)
			divisors.append(int(num / i))
		i += 1
	divisors.sort()
	return divisors
n = int(input())
d = list(map(int, input().split()))
d.sort()
x = d[-1]
a = finddivisors(x)
for i in a:
	if i in d:
		d.remove(i)
d.sort()
y = d[-1]
print(x, y)


n = int(input())
a = []
a = list(map(int, input().split()))
div1 = max(a)
for i in range(1, div1 + 1):
	if div1 % i == 0:
		a.remove(i)
div2 = max(a)
print(div1, div2)


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973]

def findFactors(n):
	D = {}
	for i in primes:
		while n % i == 0:
			n = int(n / i)
			if i in D:
				D[i] += 1
			else:
				D[i] = 1
		if n == 1:
			break
	return D
n = int(input())
lt = list(input().split())
l = len(lt)
D = {}
for i in range(l):
	lt[i] = int(lt[i])
	if lt[i] in D:
		D[lt[i]] += 1
	else:
		D[lt[i]] = 1
b = max(lt)
a = 1
D2 = {}
lt = []
for i in D:
	if D[i] == 2:
		lt2 = findFactors(i)
		for j in lt2:
			if j in D2:
				if D2[j] < lt2[j]:
					D2[j] = lt2[j]
			else:
				D2[j] = lt2[j]
		lt.append(i)
for i in lt:
	del D[i]
for i in D:
	if b % i != 0:
		lt2 = findFactors(i)
		for j in lt2:
			if j in D2:
				if D2[j] < lt2[j]:
					D2[j] = lt2[j]
			else:
				D2[j] = lt2[j]
a = 1
for i in D2:
	a *= i ** D2[i]
print(b, a)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = set()
ans1 = a[0]
b.add(ans1)
a = a[1:]
for x in a:
	if ans1 % x == 0:
		if x in b:
			ans2 = x
			break
		b.add(x)
		continue
	ans2 = x
	break
print('{} {}'.format(ans1, ans2))


n = int(input())
lis = [int(x) for x in input().split()]
n1 = max(lis)
for i in range(1, n1 + 1):
	if n1 % i == 0:
		j = lis.index(i)
		lis[j] = 0
n2 = max(lis)
print(n1, end=' ')
print(n2)


def divList(n):
	if n == 1:
		return [1]
	l = [1, n]
	for i in range(2, n // 2 + 1):
		if n % i == 0:
			l.append(i)
	return l
n = int(input())
l = input().split()
l = [int(i) for i in l]
if n == 2:
	print(l[0], l[1])
	exit()
l.sort()
x = l[len(l) - 1]
xDiv = divList(x)
for i in range(len(l) - 2, 0, -1):
	temp = divList(l[i])
	temp += xDiv
	temp.sort()
	if temp == l:
		print(x, l[i])
		exit()


t = int(input())
inp = [int(x) for x in input().split()]
inp.sort()
a = inp[-1]
s = set()
s.add(a)
b = 1
for i in range(t - 2, -1, -1):
	if inp[i] in s or a % inp[i] != 0:
		b = inp[i]
		break
	elif a % inp[i] == 0:
		s.add(inp[i])
	else:
		pass
print(a, b)


from math import gcd
n = int(input())
A = list(map(int, input().split()))
answer = 1
a = max(A)
visited = set()
for i in range(n):
	if a % A[i] != 0 or A[i] in visited:
		answer *= A[i] // gcd(A[i], answer)
	visited.add(A[i])
print(a, answer)


n = int(input())
arr = list(map(int, input().split()))
a2 = list(set(arr[:]))
a1 = max(arr)
print(a1, end=' ')
for i in a2:
	if a1 % i == 0:
		arr.remove(i)
print(max(arr))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import Counter as C
(n,) = I()
l = I()
l.sort()
c = C(l)
f = []
a = l[-1]
for i in range(1, l[-1] + 1):
	if a % i == 0:
		f.append(i)
ans = []
for i in l:
	if i not in f or c[i] == 2:
		ans.append(i)
print(l[-1], ans[-1])


n = int(input())
arr = list(map(int, input().split()))
mx = max(arr)
div = []
for i in arr:
	if mx % i or arr.count(i) > 1:
		div.append(i)
print(str(mx) + ' ' + str(max(div)))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
x = l[0]
c = x
y = 1
for i in range(1, n):
	if l[i] == c or x % l[i] != 0:
		y = l[i]
		break
	else:
		c = l[i]
print(x, y)


n = int(input())
d = list(map(int, input().split()))
d.sort()
div = []
oth = []
x = d[-1]
for i in range(len(d)):
	if d[i] not in div and x % d[i] == 0:
		div.append(d[i])
	else:
		oth.append(d[i])
y = oth[-1]
print(x, y)


import math

def yakusu(num):
	ret = []
	for i in range(int(math.sqrt(num))):
		if num % (i + 1) == 0:
			ret.append(i + 1)
			ret.append(num // (i + 1))
	return ret
n = int(input())
d = list(map(int, input().split()))
d.sort(reverse=True)
x = d[0]
used = set([])
yak = yakusu(x)
y = 0
for i in d:
	if i in yak:
		if i not in used:
			used.add(i)
			continue
	y = max(y, i)
print(x, y)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
if d.count(x) == 2:
	print(x, x)
else:
	setd = set(d)
	notx = []
	y = []
	for i in setd:
		if x % i != 0:
			notx.append(i)
	if len(notx) != 0:
		print(x, max(notx))
	else:
		for i in setd:
			if d.count(i) == 2:
				y.append(i)
		print(x, max(y))


n = int(input())
l = list(map(int, input().split()))
a = max(l)
l.remove(a)
for i in range(2, a):
	if a % i == 0:
		l.remove(i)
b = max(l)
print(a, b)


from math import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
n = int(input())
arr = list(map(int, input().split()))
a = max(arr)
b = 0
for e in arr:
	if arr.count(e) == 2 or a % e:
		b = max(b, e)
print(a, b)


import math

def divisorGenerator(n):
	large_divisors = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			yield i
			if i * i != n:
				large_divisors.append(n / i)
	for divisor in reversed(large_divisors):
		yield divisor
n = int(input())
a = list(map(int, input().split()))
n1 = max(a)
for i in divisorGenerator(n1):
	a.remove(i)
n2 = max(a)
print('{} {}'.format(n1, n2))


n = int(input())
a = list(map(int, input().split()))
a.sort()
maxi = a[n - 1]
for i in range(1, maxi + 1, 1):
	if maxi % i == 0:
		a.remove(i)
m2 = max(a)
print(maxi, m2)


from collections import *
from math import *
n = int(input())
a = list(map(int, input().split()))
a.sort()
(x, y) = (1, a[-1])
d = dict()
for i in range(n - 1, -1, -1):
	if a[i] in d:
		x = a[i]
		break
	if y % a[i] == 0:
		d[a[i]] = 1
	else:
		x = a[i]
		break
print(x, y)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = sorted(int_array())
x = a[-1]
y = a.copy()
ns = set()
for i in a:
	if x % i == 0 and i not in ns:
		y.remove(i)
		ns.add(i)
y = max(y)
print(x, y)


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
last = x
arr.pop(arr.index(x))
while arr:
	ma = -1
	for i in range(len(arr)):
		if arr[i] > ma:
			ma = arr[i]
			ind = i
	k = arr.pop(ind)
	if k == last or x % k != 0:
		y = k
		break
	else:
		last = k
print(x, y)


n = int(input())
divs = list(map(int, input().split()))
a = max(divs)
b = -1
dic = dict()
for div in divs:
	if a % div == 0 and (div in dic) == False:
		dic[div] = 1
	else:
		b = max(b, div)
print(a, b)


(_, arr) = (input(), sorted(list(map(int, input().split())), reverse=True))
x = arr[0]
dup = 1
for num in arr:
	if num == dup:
		break
	if x % num != 0:
		break
	else:
		dup = num
print(x, num)


n = int(input())
l = list(map(int, input().strip().split()))
x = max(l)
l.remove(x)
while len(l) != 0:
	y = max(l)
	if x % y == 0:
		if x == y:
			break
		elif l.count(y) == 2:
			break
		else:
			l.remove(y)
			continue
	else:
		break
print(x, y)


from math import gcd
n = int(input())
a = [int(x) for x in input().split()]
x = max(a)
a.sort()
ans = a[0]
for i in a:
	if x % i == 0 and a.count(i) == 1:
		continue
	else:
		ans = i
print(x, ans)


def c(l1, r1, l2, r2):
	a = [[l1, r1], [l2, r2]]
	b = list(a)
	a.sort(key=lambda x: (x[0], x[1]))
	if a[0][0] == b[0][0] and a[0][1] == b[0][1] and (a[1][0] == b[1][0]) and (a[1][1] == b[1][1]):
		print(a[0][0], a[1][1])
	else:
		print(a[1][1], a[0][0])
n = int(input())
d = [int(k) for k in input().split()]
d.sort(reverse=True)
i = 1
y = 1
y0 = d[0]
x = d[0]
r = True
while i < n:
	y = d[i]
	if x % y != 0 or y0 == y:
		r = True
		break
	y0 = y
	i += 1
else:
	r = False
	print(d[0], d[1])
if r:
	print(x, y)


count = int(input())
arr = input().split()
for y in range(count):
	arr[y] = int(arr[y])
arr.sort()
x = arr[-1]
previous = x
for y in range(count - 2, -1, -1):
	if x % arr[y] != 0:
		previous = arr[y]
		break
	if arr[y] == previous:
		break
	else:
		previous = arr[y]
print(previous, x)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
xd = set()
for i in range(n):
	if d[i] not in xd and x % d[i] == 0:
		xd.add(d[i])
		d[i] = 0
print(x, max(d))


n = int(input())
a = []
b = []
h = []
for i in input().split(' '):
	a.append(int(i))
s = max(a)
p = dict()
for i in a:
	p[i] = p.get(i, 0) + 1
for i in range(1, s + 1):
	if s % i == 0:
		b.append(i)
for (j, k) in p.items():
	if j not in b:
		h.append(j)
	elif k >= 2:
		h.append(j)
r = max(h)
print(s, end=' ')
print(r)


def factors(number):
	factors = []
	for i in range(1, number + 1):
		if number % i == 0:
			factors.append(i)
	return factors
n = int(input())
fac = input().split()
fac = list(map(int, fac))
number = max(fac)
for x in factors(number):
	fac.remove(x)
number2 = max(fac)
print(number, number2)


import sys
count = int(sys.stdin.readline())
params = [int(x) for x in sys.stdin.readline().split()]

def solve(divisors):
	number_1 = max(divisors)
	max_doubled = 1
	max_absolute = 1
	duplicates = [x for x in divisors if divisors.count(x) > 1]
	non_divisors_of_1 = [x for x in divisors if number_1 % x != 0]
	if len(duplicates) > 0:
		max_doubled = max(duplicates)
	if len(non_divisors_of_1) > 0:
		max_absolute = max(non_divisors_of_1)
	number_2 = max(max_doubled, max_absolute)
	print(number_1, number_2)
	return (number_1, number_2)
solve(params)


def div(n):
	ans = []
	for i in range(1, n // 2 + 1):
		if n % i == 0:
			ans.append(i)
	if n not in ans:
		ans.append(n)
	return ans

def main():
	n = int(input())
	(x, y) = (1, 1)
	ls = sorted([int(i) for i in input().split()])
	x = max(ls)
	double = div(max(ls))
	for i in double:
		ls.remove(i)
	y = max(ls)
	print(x, y)
main()


from collections import Counter

def read_nums():
	return [int(x) for x in input().split()]

def get_divisors(n):
	for i in range(1, n + 1):
		if n % i == 0:
			yield i

def main():
	(n,) = read_nums()
	divs = read_nums()
	c = Counter(divs)
	max_key = max(c.keys())
	max_key_count = c[max_key]
	if max_key_count == 2:
		print(max_key, max_key)
	else:
		for div in get_divisors(max_key):
			c[div] -= 1
		new_max_key = max((k for k in c.keys() if c[k] > 0))
		print(max_key, new_max_key)
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	s = set()
	t = set()
	m = max(a)
	for c in a:
		if c in s or m % c != 0:
			t.add(c)
		else:
			s.add(c)
	return '{} {}'.format(m, max(t))
print(main())


def factor(x):

	def f(y, q):
		while not y % q:
			y //= q
			r[q] = r.get(q, 0) + 1
		return y
	(r, p) = ({}, 7)
	x = f(f(f(x, 2), 3), 5)
	while x >= p * p:
		for s in (4, 2, 4, 2, 4, 6, 2, 6):
			if not x % p:
				x = f(x, p)
			p += s
	if x > 1:
		f(x, x)
	return r

def divisors(x):
	r = [1]
	for (p, n) in factor(x).items():
		t = -len(r)
		for _ in range(n):
			for _ in range(t, 0):
				r.append(r[t] * p)
	return r

def main():
	input()
	l = list(map(int, input().split()))
	y = max(l)
	for d in divisors(y):
		l.remove(d)
	print(max(l), y)
main()


def solve():
	input()
	ar = []
	for i in input().split(' '):
		if i.isdigit():
			ar.append(int(i))
	ar.sort()
	x = ar[-1]
	ary = []
	deleted = 0
	for i in ar:
		if x % i != 0 or i == deleted:
			ary.append(i)
		else:
			deleted = i
	y = ary[-1]
	print(x, y)
solve()


n = int(input())
c = sorted(list(map(int, input().split())))
b = c[-1]
last = 0
for i in range(len(c)):
	if b % c[i] == 0 and c[i] != c[i - 1]:
		continue
	else:
		last = c[i]
print(last, end=' ')
print(b)


import math
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = []
x = A[0]
for (i, m) in enumerate(A):
	if i > 0 and A[i] == A[i - 1] or x % m != 0:
		B.append(m)
print(A[0], B[0])


def primeFactor(N):
	i = 2
	ret = {}
	n = N
	if n < 0:
		ret[-1] = 1
		n = -n
	if n == 0:
		ret[0] = 1
	d = 2
	sq = int(n ** (1 / 2))
	while i <= sq:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
			ret[i] = k
		if k > 0:
			sq = int(n ** (1 / 2))
		if i == 2:
			i = 3
		elif i == 3:
			i = 5
		elif d == 2:
			i += 2
			d = 4
		else:
			i += 4
			d = 2
	if n > 1:
		ret[n] = 1
	return ret

def isPrime(N):
	if N <= 1:
		return False
	return sum(primeFactor(N).values()) == 1

def findPrime(N):
	if N < 0:
		return -1
	i = N
	while True:
		if isPrime(i):
			return i
		i += 1

def divisors(N):
	pf = primeFactor(N)
	ret = [1]
	for p in pf:
		ret_prev = ret
		ret = []
		for i in range(pf[p] + 1):
			for r in ret_prev:
				ret.append(r * p ** i)
	return sorted(ret)
n = int(input())
X = [int(a) for a in input().split()]
a = max(X)
D = divisors(a)
for d in D:
	X.remove(d)
b = max(X)
print(a, b)


def find_divs(divisors):
	num = max(divisors)
	divs = set()
	for d in divisors:
		if num % d == 0:
			divs.add(d)
	return (num, divs)

def solve(divisors):
	counts = {}
	for d in divisors:
		if d not in counts:
			counts[d] = 1
		else:
			counts[d] += 1
	divisors = set(divisors)
	(num1, divs1) = find_divs(divisors)
	for d in divs1:
		if counts[d] == 1:
			divisors.remove(d)
	(num2, divs2) = find_divs(divisors)
	print('{} {}'.format(num1, num2))
n = int(input())
divisors = list(map(int, input().strip().split()))
solve(divisors)


a = input()
a = list(map(int, input().split()))
a.sort()
result1 = a[len(a) - 1]
result2 = 0
index = len(a) - 2
prev = result1
while index >= 0:
	if result1 % a[index] == 0:
		if a[index] == prev:
			result2 = a[index]
			break
		else:
			prev = a[index]
	else:
		result2 = a[index]
		break
	index = index - 1
print(str(result1) + ' ' + str(result2))


n = int(input())
numbers = list(map(int, input().strip().split()))
numbers.sort(reverse=True)
num1 = numbers[0]
num2 = 0
for i in numbers[1:]:
	if numbers.count(i) == 2 or num1 % i != 0:
		num2 = i
		break
print(num1, num2)


n = int(input())
delims = list(map(int, input().strip().split()))
delims.sort(reverse=True)
first = delims[0]
second = delims[1]
second_init = delims[1]
if n > 2 and first != second:
	diff = first % second
	found = False
	found_s = False
	for i in range(2, n):
		if not found_s and second_init != delims[i]:
			second_init = delims[i]
		else:
			found_s = True
		if diff == 0:
			second = delims[i]
			diff = first % second
		else:
			found = True
			break
	if not found:
		second = second_init
print(first, second)


n = int(input())
d = [*map(int, input().split())]
mp = {}
for e in d:
	mp[e] = mp[e] + 1 if e in mp else 1

def divDecr(maxi):
	for e in [*mp.keys()]:
		if maxi % e == 0:
			mp[e] -= 1
		if mp[e] == 0:
			del mp[e]
x = max(mp)
divDecr(x)
y = max(mp)
print(x, y)


from collections import *
n = int(input())
nums = [int(x) for x in input().split()]
(x, y) = (max(nums), -1)
for num in nums:
	if x % num:
		y = max(y, num)
if y == -1:
	Cnter = Counter(nums)
	cntlist = list(filter(lambda x: Cnter[x] > 1, Cnter.keys()))
	y = max(cntlist)
print(x, y)


from math import gcd
n = int(input())
k = []
p = []
arr = [int(x) for x in input().split()]
g = max(arr)
print(g, end=' ')
for i in arr:
	if g % i == 0 and i not in k:
		k.append(i)
	else:
		p.append(i)
lcm = p[0]
for i in p[1:]:
	lcm = lcm * i // gcd(lcm, i)
print(lcm)


q = int(input())
l = list(map(int, input().split()))
a = max(l)
if l.count(a) > 1:
	print(a, a)
	exit(0)
ll = [1]
for i in range(q):
	if a % l[i] != 0 or l.count(l[i]) > 1:
		ll += [l[i]]
print(a, max(ll))


n = int(input())
num = list(map(int, input().split()))
num.sort(reverse=True)
div = []
x = num[0]
y = 0
for q in range(n):
	if x % num[q] != 0:
		y = num[q]
	elif num[q] not in div:
		div.append(num[q])
div2 = []
while len(div) > 0:
	num.pop(num.index(div[-1]))
	div.pop()
y = max(num)
print(x, y)


from collections import Counter
import math
n = int(input())
a = list(map(int, input().split()))
m = max(a)
c = Counter(a)

def divisors(n):
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				c[i] -= 1
			else:
				c[i] -= 1
				c[int(n / i)] -= 1
				if c[int(n / i)] == 0:
					del c[int(n / i)]
			if c[i] == 0:
				del c[i]
divisors(m)
print(m, max(c.keys()))


__author__ = 'Dilshod'
n = int(input())
m = list(map(int, input().split()))
m.sort(reverse=True)
ans = [m[0]]
for i in range(1, n):
	if m[0] % m[i] != 0 or m[i - 1] == m[i]:
		ans.append(m[i])
		print(ans[0], ans[1])
		exit()


import math
n = int(input())
a = list(map(int, input().split()))
s = max(a)
a.remove(s)
for i in range(1, s):
	if s % i == 0:
		a.remove(i)
d = max(a)
print(s, ' ', d)


n = int(input())
a = list(map(int, input().split()))
s = max(a)
del1 = []
l = 0
for i in range(len(a)):
	r = 0
	for j in del1:
		if a[i] == j:
			r = r + 1
	if s % a[i] == 0 and a[i] != s and (r == 0):
		del1.append(a[i])
		a[i] = 0
	elif a[i] == s and l == 0:
		a[i] = 0
		l = l + 1
k = 0
b = max(a)
if b == 0:
	b = max(del1)
	if b == s:
		b = 1
print(s, b)


n = int(input())
a = []
temp = input()
cur = 0
for i in range(0, len(temp)):
	if temp[i] == ' ':
		b = temp[cur:i]
		a.append(int(b))
		cur = i + 1
b = temp[cur:len(temp) + 1]
a.append(int(b))
maxi = max(a)
for i in range(1, maxi + 1):
	if maxi % i == 0:
		a.remove(i)
num2 = max(a)
print(maxi, num2)


n = int(input())
m = list(map(int, input().split()))
m.sort()
a = m[-1]
mas = []
for i in range(1, int(a ** (1 / 2)) + 1):
	if not a % i:
		mas.append(i)
		mas.append(a // i)
mas = list(set(mas))
mas.sort()
for i in mas:
	m.pop(m.index(i))
m.sort()
print(a, m[-1])


import copy
import itertools
import string
import sys

def powmod(x, p, m):
	if p <= 0:
		return 1
	if p <= 1:
		return x % m
	return powmod(x * x % m, p // 2, m) * (x % m) ** (p % 2) % m

def to_basex(num, x):
	while num > 0:
		yield (num % x)
		num //= x

def from_basex(it, x):
	ret = 0
	p = 1
	for d in it:
		ret += d * p
		p *= x
	return ret

def core():
	n = int(input())
	d = [int(x) for x in input().split()]
	s = set(d)
	ms = {di: d.count(di) for di in s}
	x = max(s)
	for di in s:
		if x % di == 0:
			ms[di] -= 1
	sy = {di for (di, cnt) in ms.items() if cnt > 0}
	y = max(sy)
	ans = (x, y)
	print(*ans)
core()


n = int(input())
A = list(map(int, input().split()))
A.sort()
i = n - 1
j = n - 2
while i >= 0 and j >= 0:
	if A[i] == A[j]:
		print(A[i], A[j])
		break
	if A[i] % A[j] == 0 and A.count(A[j]) > 1:
		print(A[i], A[j])
		break
	if A[i] % A[j] == 0:
		j -= 1
	if A[i] % A[j] != 0:
		print(A[i], A[j])
		break


n = int(input())
li = list(map(int, input().split()))
a = max(li)
li.remove(a)
for i in range(1, a // 2 + 1):
	if a % i == 0:
		li.remove(i)
b = max(li)
print(a, end=' ')
print(b)


temp = input()
lst = input().split(' ')
lst = [int(x) for x in lst]
lst.sort()
import math

def divisorGenerator(n):
	large_divisors = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			yield i
			if i * i != n:
				large_divisors.append(n / i)
	for divisor in reversed(large_divisors):
		yield divisor
res = []
while lst != []:
	num = lst[-1]
	z = list(divisorGenerator(num))
	for m in z[::-1]:
		lst.remove(m)
	res.append(num)
res = ' '.join((str(item) for item in res))
print(res)


import math

def divisorGenerator(n):
	large_divisors = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			yield i
			if i * i != n:
				large_divisors.append(n / i)
	for divisor in reversed(large_divisors):
		yield int(divisor)
n = input()
list_of_numbers = list(map(int, input().split(' ')))
y = max(list_of_numbers)
list_of_y_divisors = list(divisorGenerator(y))
list_of_x_divisors = []
for div in list_of_numbers:
	if div not in list_of_y_divisors or list_of_numbers.count(div) > 1:
		list_of_x_divisors.append(div)
print(y, max(list_of_x_divisors))


count = int(input())
arr = [int(x) for x in input().split()]
a = max(arr)
b = 0
arr2 = set()
for i in range(len(arr)):
	if a % arr[i] != 0:
		arr2.add(arr[i])
	if arr.count(arr[i]) > 1:
		arr2.add(arr[i])
print(a, max(arr2))


n = int(input())
d = list(map(int, input().split()))
x = max(d)
for i in range(1, x + 1):
	if x % i == 0:
		d.remove(i)
t = max(d)
print(x, t, sep=' ')


import math
n = int(input())
array = list(map(int, input().strip().split()))
array = sorted(array, reverse=True)
x = array[0]

def divisors(numb):
	div = set()
	for i in range(1, int(math.sqrt(numb) + 1)):
		if numb % i == 0:
			div.add(i)
			div.add(numb // i)
	return div
max_div = divisors(x)

def find():
	for i in range(len(array) - 1):
		if not array[i] in max_div:
			return array[i]
		elif array[i + 1] == array[i]:
			return array[i]
y = find()
print(*[x, y])


from collections import Counter
N = int(input())
D = Counter(map(int, input().split()))
M = max(D)
U = set((d for d in D if M % d == 0))
print(M, max(D - Counter(U)))


from math import sqrt, ceil
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
v1 = max(d)
c = Counter(d)
c[v1] -= 1
for i in range(2, v1 // 2 + 1):
	if v1 % i == 0:
		c[i] -= 1
print(v1, max(filter(lambda x: c[x] > 0, c)))


n = int(input())
arr = list(map(int, input().split()))
maxi = max(arr)
s = str(maxi) + ' '
temp = []
for i in arr:
	if maxi % i == 0 and i not in temp:
		temp.append(i)
for j in temp:
	arr.remove(j)
s += str(max(arr))
print(s)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
while a:
	d = a.pop()
	if x % d != 0 or (a and a[-1] == d):
		y = d
		break
print(x, y)


import math

def allDivisors(n):
	i = 1
	l = []
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(int(n / i))
		i = i + 1
	return l
n = int(input())
s = list(map(int, input().split(' ')))
k = max(s)
d = {x: s.count(x) for x in s}
fac = allDivisors(k)
l = [item for item in s if item not in fac]
for i in s:
	if d[i] == 2:
		l.append(i)
a = max(l)
print(k, a, sep=' ')


i = int(input())
l = list(map(int, input().split()))
p = []
m = max(l)
for x in l:
	if m % x != 0:
		p.append(x)
	if l.count(x) > 1:
		p.append(x)
print(m, max(p))


def main():
	N = int(input())
	A = list(map(int, input().split()))
	x = max(A)
	y = 1
	factorsSet = set()
	for n in A:
		if x % n == 0 and n not in factorsSet:
			factorsSet.add(n)
		else:
			y = max(y, n)
	print(x, y)
main()


def ans(a):
	x = a.pop()
	save = {}
	if x == a[len(a) - 1]:
		return [x, x]
	while a:
		y = a.pop()
		if x % y != 0 or y in save:
			break
		save[y] = 1
	return [x, y]
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
print(*ans(a))


n = int(input())
l = list(map(int, input().split(' ')))
m = max(l)
i = 1
while i * i <= m:
	if m % i == 0:
		if len(l) > 0 and i in l:
			l.remove(i)
		if len(l) > 0 and m // i in l and (i != m // i):
			l.remove(m // i)
	i += 1
print(m, max(l))


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
b = []
i = 0
while i < len(a):
	if a[i] not in b and x % a[i] == 0:
		b.append(a[i])
		a.remove(a[i])
	else:
		i += 1
y = a[-1]
print(x, y)


n = int(input())
divisors = list(map(int, input().split()))
one = max(divisors)
one_set = list()
for i in range(1, one + 1):
	if one % i == 0:
		one_set.append(i)
		divisors.remove(i)
second = max(divisors)
print('{0} {1}'.format(one, second))


n = int(input())
l = list(map(int, input().split()))
x = []
z = max(l)
for i in range(1, z):
	if z % i == 0:
		if z // i in l:
			l.pop(l.index(z // i))
print(z, max(l))


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
x = max(arr)
xx = []
yy = []
for i in arr:
	a = i not in xx
	if x % i == 0 and a:
		xx.append(i)
	else:
		yy.append(i)
y = max(yy)
print(x, y)


n = int(input())
d = [int(x) for x in input().split()]
if n == 2:
	print(1, 1)
else:
	d.sort()
	m = d[-1]
	for i in range(n - 2, -1, -1):
		if m % d[i] != 0:
			n = d[i]
			break
		if d.count(d[i]) == 2:
			n = d[i]
			break
	print(m, n)


n = int(input())
d = [int(x) for x in input().split()]
x = max(d)
(s, s1) = ([], [])
for i in d:
	if x % i == 0 and i not in s:
		s.append(i)
	else:
		s1.append(i)
if s == s1:
	print(x, x)
else:
	print(x, max(s1))


n = int(input())
a = list(map(int, input().split()))
s = []
r = max(a)
if len(a) == 2 and a.count(1) == 2:
	print('1 1')
else:
	for i in range(2, r + 1):
		if r % i == 0:
			s.append(i)
	s.append(1)
	x = {}
	for i in s:
		x[i] = -1
	for i in a:
		if x.get(i):
			x[i] = x[i] + 1
		else:
			x[i] = 1
	p = 0
	for i in x:
		if x[i] == 1:
			if p < i:
				p = i
	print(r, end=' ')
	print(p)


n = int(input())
l = sorted([int(i) for i in input().split()])
x = l[-1]
for i in range(1, x + 1):
	if x % i == 0:
		l.remove(i)
print(x, l[-1])


n = int(input())
div = sorted(tuple(map(int, input().split())), reverse=True)
a1 = [div[0]]
a = div[0]
for i in sorted(div[1:], reverse=True):
	if a % i == 0 and i not in a1:
		a1.append(i)
	else:
		b = i
		print(a, b)
		break


n = int(input())
d = sorted(list(map(int, input().split())))
hope = [1] * n
hope[n - 1] = 0
x = d[n - 1]
for i in range(n - 1):
	if x % d[i] == 0 and d[i] != d[i + 1]:
		hope[i] = 0
i = n - 1
while hope[i] == 0:
	i -= 1
print(x, d[i])


n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l[len(l) - 1]
a = []
for i in range(len(l)):
	a.append(0)
for i in range(0, len(l)):
	if x % l[i] == 0:
		if i == 0:
			a[0] = 1
		elif l[i] != l[i - 1]:
			a[i] = 1
b = []
for i in range(len(a)):
	if a[i] == 0:
		b.append(l[i])
y = b[len(b) - 1]
li = [x, y]
for i in li:
	print(i, end=' ')


import sys
from atexit import register
from collections import Counter
from functools import reduce
from io import FileIO, StringIO
sys.stdin = StringIO(FileIO(0).read().decode())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = StringIO()
register(lambda : FileIO(1, 'w').write(sys.stdout.getvalue().encode()))

def main():
	n = input()
	a = Counter(map(int, input().split()))
	p = max(a.keys())

	def all_factors(n):
		return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1, 2 if n % 2 else 1) if n % i == 0)))
	for f in all_factors(p):
		a[f] -= 1
		if a[f] == 0:
			del a[f]
	g = max(a.keys())
	print(p, g)
main()


def main():
	_n = int(input())
	divisor_list = [int(x) for x in input().split(' ')]
	x = max(divisor_list)
	divisor_count = construct_divisor_count(divisor_list)
	y_divisor_list = []
	for divisor in divisor_count:
		if x % divisor == 0:
			if divisor_count[divisor] == 2:
				y_divisor_list.append(divisor)
				divisor_count[divisor] -= 1
			else:
				pass
		else:
			y_divisor_list.append(divisor)
	print(x, max(y_divisor_list))

def construct_divisor_count(divisor_list):
	divisor_count = {}
	for divisor in divisor_list:
		if divisor in divisor_count:
			divisor_count[divisor] += 1
		else:
			divisor_count[divisor] = 1
	return divisor_count
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
if all((x % y == 0 for y in a)):
	for (l, r) in zip(a, a[1:]):
		if l == r:
			y = r
else:
	y = max((y for y in a if x % y != 0))
print(x, y)


n = int(input())
lis = list(map(int, input().split()))
m = max(lis)
has = [0] * 100005
for i in lis:
	has[i] += 1
for i in range(n):
	if m % lis[i] == 0:
		has[lis[i]] -= 1
		if has[lis[i]] == 0:
			lis[i] = 0
print(m, max(lis))


n = int(input())
seq = sorted(list(map(int, input().split())))[::-1]
a = seq[0]
last = -1
for i in range(len(seq)):
	if a % seq[i] == 0:
		if last != seq[i]:
			last = seq[i]
		else:
			b = seq[i]
			break
	else:
		b = seq[i]
		break
print(a, b)


n = int(input())
s = sorted([int(i) for i in input().split()])
e = set()
c = s[-1]
d = []
f = []
for i in range(n):
	if c % s[i] == 0 and s[i] not in e:
		d.append(s[i])
		e.add(s[i])
	else:
		f.append(s[i])
print(max(d), max(f))


input()
q = [*map(int, input().split())]
m = max(q)
print(m, max((k for k in q if m % k or q.count(k) > 1)))


from functools import reduce
n = int(input())
d = list(map(int, input().split()))
set_x = set()
set_y = set()
d.sort(key=lambda x: -x)
div = None
for i in d:
	if div == None:
		div = i
	if div % i == 0 and i not in set_x:
		if len(set_x) == 0:
			x = i
		set_x.add(i)
	else:
		y = i
		break
print(x, y)


def io():
	return map(int, input().split())

def op():
	return list(map(int, input().split()))

def div(n):
	l = []
	i = 1
	ap = l.append
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				ap(i)
			else:
				ap(i)
				ap(n // i)
		i += 1
	return l
n = int(input())
l = op()
ans = [max(l)]
x = div(max(l))
for i in x:
	l.remove(i)
ans.append(max(l))
ans.sort()
print(*ans)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
l = l[::-1]
a = l[0]
for i in set(l):
	if a % i == 0:
		l.remove(i)
print(a, l[0])


n = int(input())
d = sorted(map(int, input().split()))
print(d[-1], end=' ')
x = []
for i in range(1, d[-1] + 1):
	if d[-1] % i == 0:
		x.append(i)
for i in reversed(d):
	if i not in x and d.count(i) == 1 or d.count(i) == 2:
		print(i)
		break


n = int(input())
d = list(map(int, input().split()))
d.sort(key=lambda x: -x)
print(d[0], end=' ')
for i in range(1, n):
	if d[0] % d[i] != 0:
		print(d[i])
		exit()
for i in range(n - 1):
	if d[i] == d[i + 1]:
		print(d[i])
		exit()


Cantidad = int(input())
Lista = sorted([int(x) for x in input().split()])
Maximo = Lista[-1]
print(Maximo, max([k for k in Lista if Maximo % k or Lista.count(k) > 1]))


import math
n = int(input())
nums = list(map(int, input().rstrip().split()))
if n == 2:
	print(*nums)
else:
	m = max(nums)
	result_m = []
	for i in range(1, math.floor(math.sqrt(m)) + 1):
		if m % i == 0:
			if i not in result_m:
				result_m.append(i)
			if int(m / i) not in result_m:
				result_m.append(int(m / i))
	nums.sort()
	result_m.sort()
	nums = nums[:][::-1]
	result_m = result_m[:][::-1]
	condition = True
	for j in range(0, len(result_m)):
		if nums[j] != result_m[j]:
			print(m, nums[j])
			condition = False
			break
	if condition:
		print(m, 1)


import math

def primenum(x):
	count = 0
	for i in range(2, int(math.floor(math.sqrt(x))) + 1):
		if x % i == 0:
			count = count + 1
	if count == 0:
		return True
	else:
		return False
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n - 2, -1, -1):
	if a.count(math.gcd(max(a), a[i])) == 2:
		z = a[i]
		break
if primenum(max(a)) == True:
	q = max(a)
	a.remove(q)
	q1 = max(a)
	print(q, q1)
else:
	print(max(a), z)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
x = 1
y = max(l)
for i in s:
	if y % i != 0:
		for j in range(max(i, x), x * i + 1):
			if j % x == 0 and j % i == 0:
				x = j
				break
		x = max(x, i)
	elif l.count(i) > 1:
		for j in range(max(i, x), x * i + 1):
			if j % x == 0 and j % i == 0:
				x = j
				break
		x = max(x, i)
print(x, y)


n = int(input())
s = [int(x) for x in input().split()]
b = max(s)
for i in range(int(b / 2)):
	if b % (i + 1) == 0:
		s.remove(i + 1)
s.remove(b)
c = max(s)
print(b, end=' ')
print(c)


input()
x = list(map(int, input().split()))
a = max(x)
for i in range(1, a + 1):
	if not a % i:
		x.remove(i)
print(a, max(x))


n = int(input())
arr = list(map(int, input().split()))
ans1 = max(arr)
arr2 = []
for i in range(1, ans1 + 1):
	if ans1 % i == 0:
		for j in range(n):
			if arr[j] == i:
				arr[j] = -1
				break
ans2 = max(arr)
print(ans1, end=' ')
print(ans2)


n = int(input())
dev = list(map(int, input().split()))
dev.sort()
x = dev[-1]
i = -2
while True:
	if dev[i] == dev[i + 1] or x % dev[i] != 0:
		print(x, dev[i])
		break
	i -= 1


import math

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
d = invr()
d = sorted(d, reverse=True)
a = d[0]
b = 0
div_a = [d[0]]
for i in range(1, n):
	if a % d[i] == 0 and d[i] not in div_a:
		div_a.append(d[i])
	else:
		b = max(b, d[i])
print(a, b)


n = int(input())
k = list(map(int, input().split()))
div = []
a = max(k)
print(a, end=' ')
for item in k:
	if a % item == 0:
		div.append(item)
div = list(dict.fromkeys(div))
for item in div:
	k.remove(item)
print(max(k))


(lambda C: (lambda N, n: (lambda k: print(max(n), max(n - C((i for i in range(1, k + 1) if k % i == 0)))))(max(n)))(int(input()), C(map(int, input().split()))))(__import__('collections').Counter)


n = int(input())
a = list(map(int, input().split()))
d = dict()
a.sort()
for i in a:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
d[a[n - 1]] -= 1
s = set()
for i in range(n - 1):
	if a[i] not in s and a[n - 1] % a[i] == 0 and (a[i] < a[n - 1]):
		d[a[i]] -= 1
		s.add(a[i])
print(a[n - 1], end=' ')
m = -1
for i in d.keys():
	if d[i] > 0:
		m = max(m, i)
print(m)


from math import *
import sys
input = sys.stdin.readline
n = int(input())
d = sorted(list(map(int, input().split())))
for i in range(n):
	for j in range(i + 1, n):
		if d[j] % d[i] == 0 and d.count(d[i]) < 2:
			d[i] = 0
			break
d = list(filter(lambda x: x != 0, d))
print(d[-2], d[-1])


def all_divs(x, stat):
	d = 1
	while d * d < x:
		if x % d == 0:
			stat[d] -= 1
			stat[x // d] -= 1
		d += 1
	if d * d == x:
		stat[d] -= 1

def solution(d):
	stat = [0] * (max(d) + 1)
	for x in d:
		stat[x] += 1
	all_divs(max(d), stat)
	for i in range(len(stat) - 1, -1, -1):
		if stat[i] != 0:
			return (i, max(d))
n = int(input())
d = list(map(int, input().split()))
print(*solution(d))


no_of_divisors = int(input())
all_divisors = list(map(int, input().split(' ')))

def getLowerDivisors(num):
	return [i for i in range(1, num // 2 + 1) if num % i == 0]

def getUpperDivisors(num):
	return [num // i for i in getLowerDivisors(num)]

def getAllDivisors(num):
	return set(getLowerDivisors(num) + getUpperDivisors(num))
x = max(all_divisors)
x_divisors = getAllDivisors(x)
for i in x_divisors:
	all_divisors.remove(i)
y = max(all_divisors)
print(x, y)


n = int(input())
dels = list(map(int, input().split()))
z = max(dels)
m1 = 0
hek = dict()
fl = 0
for el in dels:
	if z % el != 0:
		m1 = max(m1, el)
	elif el != z:
		if el not in hek:
			hek[el] = 0
		hek[el] += 1
	else:
		fl += 1
if m1:
	print(z, m1)
elif fl == 1:
	m2 = 1
	for t in hek:
		if hek[t] == 2:
			m2 = max(m2, t)
	print(m2, z)
else:
	print(z, z)


import math, sys

def fac(n_, v):
	for i in range(1, n_ + 1):
		if n_ % i == 0:
			vecc[v].append(i)
			vecbf.append(i)
n = int(input())
vecbf = []
vecc = [[] for i in range(n)]
m = [int(i) for i in input().split()]
m.sort()
for i in range(n):
	fac(m[i], i)
	for j in range(i):
		vecbff = vecbf + vecc[j]
		vecbff.sort()
		if vecbff == m:
			print(m[i], m[j])
			sys.exit(0)
	vecbf.clear()


input()
x = sorted(map(int, input().split()), reverse=1)
i = x[0]
for j in x:
	if x.count(j) > 1 or i % j:
		print(i, j)
		break


n = int(input())
arr = list(map(int, input().strip().split()))
arr = sorted(arr)
m = max(arr)
a = []
mp = {}
for i in range(1, m + 1):
	if m % i == 0:
		a.append(i)
for i in range(len(arr)):
	if arr[i] in mp:
		mp[arr[i]] += 1
	else:
		mp[arr[i]] = 1
x = []
for i in range(len(arr)):
	if arr[i] not in a:
		x.append(arr[i])
	else:
		if mp[arr[i]] == 3:
			continue
		if mp[arr[i]] == 2:
			x.append(arr[i])
			mp[arr[i]] = 3
print(str(m) + ' ' + str(max(x)))


n = int(input())
l = sorted(list(map(int, input().split())))
p = []
r = l[-1]
for i in range(n):
	if r % l[n - 1 - i] == 0 and l[n - 1 - i] == l[n - 2 - i]:
		print(r, l[n - 2 - i])
		break
	elif r % l[n - 1 - i] != 0:
		print(r, l[n - 1 - i])
		break


n = int(input())
l = list(map(int, input().split()))
m = max(l)
d = []
for i in range(n):
	if m % l[i] == 0 and l[i] not in d:
		d.append(l[i])
		l[i] = 0
m2 = max(l)
print(m, m2)


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def subset(li1, li2):
	for i in li1:
		if i not in li2:
			return False
	return True

def union_min_inter(li1, li2):
	res = []
	dic = {}
	for i in li2:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for i in li2:
		if dic[i] > 1:
			dic[i] = 0
			res.append(i)
		elif dic[i] == 1:
			if i not in li1:
				res.append(i)
	return res
n = int(input())
li = sorted(list(map(int, input().split())), reverse=True)
res = []
f = 0
for i in li:
	k = list(factors(i))
	if f == 0:
		if subset(k, li):
			c = len(k)
			f = 1
			li = union_min_inter(k, li)
			res.append(i)
			if len(res) == 2:
				break
	elif subset(k, li) and len(k) + c == n:
		res.append(i)
		if len(res) == 2:
			break
print(*res)


k = int(input())
l = sorted(list(map(int, input().split())))
print(l[-1], end=' ')
n = l[-1]
a = []
for i in range(1, int(n ** 0.5 + 1)):
	if n % i == 0:
		if n / i == i:
			a.append(i)
		else:
			a.append(int(n / i))
			a.append(i)
i = 0
while i < len(a):
	l.pop(l.index(a[i]))
	i += 1
print(max(l))


n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(a[0], end=' ')
x = a[0]
i = 0
while i < n:
	if x % a[i] == 0:
		if a.count(a[i]) == 2:
			a[i] = 0
			i += 1
		else:
			a[i] = 0
	i += 1
a.sort()
print(a[n - 1])


n = int(input())
d = [*map(int, input().split())]
d.sort()
x = d[-1]
ad = []
already = [False] * 10005
for i in d:
	if x % i == 0:
		already[i] = True
for i in d:
	if not already[i]:
		ad.append(i)
	else:
		already[i] = False
print(x, max(ad))


n = int(input())
a = list(map(int, input().split()))
x = max(a)
xd = []
j = 0
while j < len(a):
	if x % a[j] == 0 and a[j] not in xd:
		xd.append(a[j])
		a.pop(j)
	else:
		j += 1
y = max(a)
print(x, y)


def main():
	n = int(input())
	input_list = [int(i) for i in input().split()]
	input_list = sorted(input_list, reverse=True)
	x = None
	for item in input_list:
		if input_list[0] % item != 0 or item == x:
			break
		x = item
	print(input_list[0], item)
main()


n = int(input())
m = list(map(int, input().split()))
m = sorted(m)
a1 = []
a2 = []
for i in m:
	if i not in a1:
		a1.append(i)
	elif i not in a2:
		a2.append(i)
for (i, e) in enumerate(a1):
	if a1[-1] % e != 0:
		a2.append(a1[i])
		a1[i] = 1
a2 = sorted(a2)
print(a1[-1], a2[-1])


def arr_inp():
	return [int(x) for x in input().split()]

def factorize(n):
	(c, ans, arr) = (1, 0, deque([]))
	while c ** 2 < n:
		if n % c == 0:
			arr.extend([c, n // c])
		c += 1
	if c ** 2 == n:
		arr.append(c)
	return sorted(arr)
from collections import *
from math import *
(n, d) = (int(input()), arr_inp())
d.sort()
(x, p) = (d[-1], 0)
(x_fac, y) = (factorize(x), -1)
for i in d:
	if p < len(x_fac) and x_fac[p] == i:
		p += 1
	else:
		y = max(y, i)
print(x, y)


n = int(input())
list_n = []
list_factors = []
liz = input().split(' ')
for i in range(n):
	list_n.append(int(liz[i]))
b = max(list_n)
for j in range(1, b + 1):
	if b % j == 0:
		list_factors.append(j)
for a in list_factors:
	if a in list_n:
		index = list_n.index(a)
		list_n.pop(index)
print(max(list_n), b)


n = int(input())
l = sorted(list(map(int, input().split())))
x = l[-1]
l.pop()
for i in range(2, x):
	try:
		if x % i == 0:
			l.remove(i)
	except:
		pass
y = sorted(l)[-1]
print(x, y)


from fractions import gcd
n = int(input().strip())
arr = list(map(int, input().strip().split()))
arr.sort()
x = arr[-1]
g = 0
for i in range(len(arr) - 1):
	if arr[i] == arr[i + 1]:
		g = max(g, arr[i])
ind = arr.index(g)
for i in range(ind, len(arr)):
	if gcd(x, arr[i]) == g:
		y = arr[i]
print(' '.join([str(x), str(y)]))


from __future__ import division, print_function
import os
import sys
from collections import Counter
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
else:
	_str = str
	str = lambda x=b'': x if type(x) is bytes else _str(x).encode()

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def main():
	n = int(input())
	d = Counter((int(di) for di in input().split()))
	a = max(d)
	b = max(d - Counter(all_factors(a)))
	print(a, b)
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):
		if self.buffer.tell():
			return self.buffer.read()
		return os.read(self._fd, os.fstat(self._fd).st_size)

	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))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', b' '), 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', b'\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip(b'\r\n')
main()


import sys
import math
import collections
data = sys.stdin.read().splitlines()
ds = list(map(int, data[1].split()))
b = max(ds)
counter = collections.Counter(ds)
for i in range(1, int(math.sqrt(b)) + 1):
	if b % i == 0:
		counter[i] -= 1
		if b // i != i:
			counter[b // i] -= 1
for key in sorted(counter, reverse=True):
	if counter[key] > 0:
		a = key
		break
print('{} {}'.format(a, b))


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
y = max(a)
b = []
for i in range(1, y // 2 + 1):
	if not y % i:
		b.append(i)
else:
	b.append(y)
	print(y, end=' ')
for i in a:
	if a.count(i) > 1 or not i in b:
		print(i)
		break


import math

class Solution:

	def __init__(self):
		self.n = int(input())
		self.d = list(map(int, input().strip().split()))

	def solution(self):
		self.d.sort(reverse=1)
		mx = self.d[0]
		for i in self.d:
			if self.d.count(i) > 1 or mx % i != 0:
				print(mx, i)
				break
ob = Solution()
ob.solution()


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = l[0]
t = [0] * 100002
j = []
for i in range(n):
	if a % l[i] == 0 and t[l[i]] != 1:
		t[l[i]] = 1
		l[i] = 1
l.sort()
print(a, l[-1])


n = int(input())
mas = list(map(int, input().split()))
test = [x for x in mas if mas.count(x) == 1]
test2 = [x for x in mas if mas.count(x) == 2]
mas.sort()
test.sort()
t_len = len(test)
i = t_len - 2
if test2 == [1]:
	print(1, max(mas))
	exit(0)
if t_len == 0:
	ans = max(mas)
	print(ans, ans)
	exit(0)
while i >= 0 and test[t_len - 1] % test[i] == 0:
	i -= 1
if i == -1:
	print(max(test2), test[t_len - 1])
else:
	print(test[t_len - 1], test[i])


n = int(input())
a = input()
div = list(map(int, a.rstrip().split()))
x = max(div)
divx = []
for i in range(1, x + 1):
	if x % i == 0:
		divx.append(i)
	else:
		pass
for el in divx:
	div.remove(el)
y = max(div)
print(str(x) + ' ' + str(y))


d = int(input())
li = [int(i) for i in input().split()]
first = max(li)
i = 0
firstdiv = []
while i < d:
	if first % li[i] == 0 and li[i] not in firstdiv:
		firstdiv.append(li.pop(i))
		d -= 1
	else:
		i += 1
second = max(li)
print(first, second)


n = int(input())
m = list(map(int, input().split()))
m.sort()
k = 1
i = 1
while i < n:
	if m[i] == m[i - 1]:
		k = m[i]
	if m[n - 1] % m[i] != 0:
		k = m[i]
	i += 1
print(m[n - 1], k)


n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, max(a) + 1):
	if max(a) % i == 0:
		s.append(i)
t = list(filter(lambda x: x not in s, a))
n = sorted(list(filter(lambda x: a.count(x) == 2, a)))
for j in range(0, len(n) - 1, 2):
	t.append(n[j])
print(max(a), max(t))
quit()


n = int(input())
seq = list(input().split())
seq = [int(i) for i in seq]
seq.sort(reverse=True)
x = seq[0]
seq1 = list(set(seq))
for i in range(len(seq1)):
	if seq1[i] in seq and x % seq1[i] == 0:
		seq.remove(seq1[i])
y = max(seq)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
r = a[-1]
for i in range(1, r + 1):
	if r % i == 0:
		a.remove(i)
a = sorted(a)
t = a[-1]
print(r, t)


n = int(input())
lista = input().split()
lista = [int(l) for l in lista]
x = max(lista)
added = []
for i in range(len(lista)):
	if lista[i] not in added and x % lista[i] == 0:
		added.append(lista[i])
		lista[i] = 'X'
fl = [i for i in lista if i != 'X']
y = max(fl)
print('{} {}'.format(x, y))


n = int(input())
deli = [int(x) for x in input().split()]
x = max(deli)
tot = []
for item in deli:
	if x % item != 0:
		tot.append(item)
dic = {}
for item in deli:
	if item not in dic:
		dic[item] = 1
	else:
		dic[item] += 1
for item in dic:
	if dic[item] > 1:
		tot.append(item)
print(x, max(tot))


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
if arr[n - 1] == arr[n - 2]:
	print(arr[n - 1], arr[n - 1])
else:
	y = arr[n - 1]
	a = []
	for i in range(1, y + 1):
		if y % i == 0:
			if i in arr:
				x = arr.index(i)
				del arr[x]
	print(max(arr), y)


n = int(input())
d = list(map(int, input().split()))
d = sorted(d, reverse=True)
for i in range(n):
	if d[0] % d[i] != 0:
		print(d[0], d[i])
		break
	elif d[i] == d[i + 1]:
		print(d[0], d[i])
		break


for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	p = set(a)
	b = list(p)
	f = [0] * 100005
	for i in a:
		f[i] += 1
	k = max(a)
	for i in b:
		if k % i == 0:
			f[i] -= 1
	s = 1
	for i in a:
		if f[i] > 0:
			s = max(s, i)
	print(k, s)


import math
i = int(input())
y = 0
ant = 0
lista = list(map(int, input().split()))
lista.sort(reverse=True)
x = lista.pop(0)
if lista[0] == x:
	y = lista[0]
	print('%d %d' % (x, y))
else:
	for i in lista:
		if x % i != 0 or i == ant:
			y = i
			break
		ant = i
	print('%d %d' % (x, y))


n = int(input())
l = list(map(int, input().split()))
l.sort()
k = l[n - 1]
c = 1
r = 1
p = 1
for i in range(n - 1):
	if k % l[i] != 0:
		r = max(r, l[i])
	if l[n - i - 1] == l[n - i - 2] and c == 1:
		p = l[n - i - 1]
		c = 0
if r == 1:
	print(k, p)
else:
	print(k, r)


num = int(input())
l = []
a = input()
a = a.split(' ')
for i in a:
	l.append(int(i))
num1 = max(l)
for i in range(1, num1 + 1):
	if num1 % i == 0:
		l.remove(i)
num2 = max(l)
print(num1, num2)


n = int(input())
s = list(map(int, input().split()))
s.sort()
print(s[-1], end=' ')
for i in range(1, s[-1] + 1):
	if s[-1] % i == 0:
		s.remove(i)
print(s[-1])


x = int(input())
b = []
c = []
a = [int(x) for x in input().split()]
maxelement = max(a)
i = 0
while i < x:
	if maxelement % a[i] == 0 and a[i] not in b:
		b.append(a[i])
	else:
		c.append(a[i])
	i += 1
print(maxelement, max(c))


import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n - 2, -1, -1):
	if a.count(math.gcd(max(a), a[i])) == 2:
		z = a[i]
		break
print(max(a), z)


from collections import defaultdict
dict = {}
dict = defaultdict(lambda : 0, dict)
n = int(input())
a = [int(x) for x in input().split()]
x = max(a)
for i in range(len(a)):
	if dict[a[i]] == 0 and x % a[i] == 0:
		dict[a[i]] = 1
	elif dict[a[i]] == 1:
		dict[a[i]] = 0
y = 0
for i in dict.keys():
	if dict[i] == 0 and i > y:
		y = i
print(x, y)


t = int(input())
x = list(map(int, input().split()))
x.sort()
a = x[-1]
for i in range(1, a + 1):
	if a % i == 0:
		x.remove(i)
print(a, x[-1])


import sys
import math

def getAndParseInt(num=1):
	string = sys.stdin.readline().strip()
	if num == 1:
		return int(string)
	else:
		return [int(part) for part in string.split()]

def getAndParseString(num=1, delim=' '):
	string = sys.stdin.readline().strip()
	if num == 1:
		return string
	else:
		return [part for part in string.split(delim)]
n = getAndParseInt()
divs = getAndParseInt(2)
x = max(divs)
x_divs = {}
y_divs = []
for (index, val) in enumerate(divs):
	if x % val == 0 and val not in x_divs:
		x_divs[val] = 1
	else:
		y_divs.append(val)
y = max(y_divs)
print(x, y)


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
b = 1
for i in range(n - 2, -1, -1):
	if l[i] == l[i + 1]:
		b = l[i]
		break
	if a % l[i] != 0:
		b = l[i]
		break
print(a, b)


n = input()
n = [int(i) for i in input().split()]
a = max(n)
if n.count(a) == 2:
	print(a, a)
elif set(filter(lambda x: max(n) % x != 0, n)) == set():
	print(a, max(filter(lambda x: n.count(x) == 2, n)))
else:
	print(a, max(set(filter(lambda x: a % x != 0, n))))


n = int(input())
A = list(map(int, input().split()))
B = []
ans = max(A)
for i in range(n):
	if A[i] not in B and ans % A[i] == 0:
		B.append(A[i])
		A[i] = 0
print(ans, max(A))


from collections import *
R = lambda : map(int, input().split())
(n, a) = (R(), R())
d = Counter(a)
m = max(d)
print(m, max((k for k in d if m % k or d[k] > 1)))


n = int(input())
arr = input()
t = arr
t = [int(i) for i in t.split()]
arr = [int(k) for k in arr.split()]
q = max(arr)
o = []
l2 = []
for i in range(len(arr)):
	if q % arr[i] == 0 and arr[i] not in o:
		o.append(arr[i])
		t[i] = 1
	else:
		pass
t.sort(reverse=True)
print(q, int(t[0]))


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	n1 = arr[-1]
	arr.remove(n1)
	for i in range(1, n1 // 2 + 1):
		if n1 % i == 0:
			arr.remove(i)
	n2 = arr[-1]
	print(n1, n2)
main()


(n, d) = (int(input()), sorted(map(int, input().split())))
(x, y) = (max(d), 0)
for i in range(n - 1, 0, -1):
	if x % d[i] == 0 and d[i] == d[i - 1] or x % d[i] != 0:
		y = d[i]
		break
print(x, y)


n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l[n - 1]
l1 = []
i = 1
while i < n:
	if l[i] == l[i - 1] or x % l[i] != 0:
		l1.append(l[i])
	i += 1
y = max(l1)
print(y, x)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		ds = []
		for i in range(0, n):
			d = self.next_int()
			ds.append(d)
		ds.sort()
		for i in range(n - 2, -1, -1):
			if ds[i] == ds[i + 1] or ds[n - 1] % ds[i] != 0:
				print(ds[n - 1], ds[i])
				return
Main().solve()


n = int(input())
a = list(map(int, input().split()))
h = [0] * 20001
a.sort()
for i in range(n):
	h[a[i]] += 1
p = max(a)
fl = 0
for i in range(1, 20001):
	if p % i == 0:
		h[i] -= 1
for i in range(20001 - 1, 1, -1):
	if h[i] >= 1:
		ans = i
		fl = 1
		break
if fl == 0:
	ans = 1
print(str(p) + ' ' + str(ans))


n = int(input())
d = list(map(int, input().split()))
m = max(d)
for i in range(1, m + 1):
	if m % i == 0:
		d.remove(i)
print(m, max(d))


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
visited = set()
ys = set()
for i in range(n):
	if x % arr[i] == 0 and arr[i] not in visited:
		visited.add(arr[i])
	else:
		ys.add(arr[i])
print(x, max(ys))


t = int(input())
inar = list(map(int, input().split()))
x = max(inar)
xs = []
ys = []
for ina in inar:
	if inar.count(ina) == 2:
		xs.append(ina)
		ys.append(ina)
	elif x % ina == 0:
		xs.append(ina)
	else:
		ys.append(ina)
print('{} {}'.format(x, max(ys)))


from collections import Counter

def factors(n):
	return [d for d in range(1, n + 1) if n % d == 0]
n = int(input())
factor_counter = Counter((int(x) for x in input().split(' ')))
n1 = max((k for (k, v) in factor_counter.items()))
factor_counter.subtract(factors(n1))
n2 = max((k for (k, v) in factor_counter.items() if v > 0))
print(f'{n1} {n2}')


n = int(input())
d = list(map(int, input().split()))
d.sort(reverse=True)
x = d[0]
x_yakusuu = []
for i in range(1, 10001):
	if x % i == 0:
		x_yakusuu.append(i)
for i in x_yakusuu:
	d.remove(i)
d.sort(reverse=True)
print(str(x) + ' ' + str(d[0]))


n = int(input())
a = [0] * n
div1 = []
a = list(map(int, input().split()))
max1 = 0
for i in range(n):
	if a[i] > max1:
		max1 = a[i]
for i in range(n):
	if max1 % a[i] == 0 and a[i] not in div1:
		div1.append(a[i])
		a[i] = 0
max2 = 0
for i in range(n):
	if a[i] > max2:
		max2 = a[i]
print(max1, max2)


def main():
	n = int(input())
	L = [int(x) for x in input().split()]
	solver(L)

def solver(L):
	x = max(L)
	y = 1
	visited = set()
	for i in range(len(L)):
		num = L[i]
		if num not in visited and x % num == 0:
			visited.add(num)
		elif num > y:
			y = num
	print(x, y)
main()


n = int(input())
mat = list(map(int, input().split()))
mat = sorted(mat)
c = mat[-1]
b = 1
for i in range(n - 2, -1, -1):
	if c == mat[i]:
		b = mat[i]
		break
	elif mat[-1] % mat[i] == 0:
		c = mat[i]
		pass
	else:
		b = mat[i]
		break
print(mat[-1], b)


t = int(input())
l = list(map(int, input().split()))
m = max(l)
l1 = list()
l2 = list()
for i in l:
	if m % i == 0 and i not in l1:
		l1.append(i)
	else:
		l2.append(i)
print(max(l1), max(l2))


n = int(input())
a = [int(x) for x in input().split()]
mx = max(a)
mn = 1
hsh = [0] * 10005
for i in range(len(a)):
	if mx % a[i] == 0 and hsh[a[i]] == 0:
		hsh[a[i]] = 1
		a[i] = 1
print(mx, max(a))


n = int(input())
div = list(map(int, input().split()))
div = sorted(div)
last = div[-1]
div = div[:-1]
seen = set()
new = []
for x in div:
	if x in seen:
		new.append(x)
		continue
	if last % x == 0 and x != last:
		seen.add(x)
	else:
		new.append(x)
print(last, new[-1])


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
b = []
for i in range(n):
	if x % a[i] == 0:
		if i < n - 1 and a[i] == a[i + 1]:
			b.append(a[i])
	else:
		b.append(a[i])
b.sort()
y = b[len(b) - 1]
print(x, y)


n = int(input())
d = sorted([int(i) for i in input().split()])[::-1]
x = [d[0]]
y = []
for i in range(0, n):
	if d[i] == d[i - 1]:
		y.append(d[i])
	elif x[0] % d[i] == 0:
		x.append(d[i])
	else:
		y.append(d[i])
d = sorted(d)[::-1]
x = sorted(x)[::-1][0]
y = sorted(y)[::-1][0]
print(x, y)


n = int(input())
num_list = list(map(int, input().split()))
a1 = max(set(num_list))
for i in range(1, a1 + 1):
	if a1 % i == 0:
		num_list.remove(i)
a2 = max(num_list)
print(a1, a2)


def divisors():
	l = int(input())
	n = list(map(int, input().split()))
	n.sort()
	ind = n[l - 1]
	n.remove(ind)
	for i in range(1, ind):
		if ind % i == 0:
			n.remove(i)
		else:
			pass
	o = len(n)
	print(ind, end=' ')
	print(n[o - 1])
divisors()


n_divisors = int(input())

def findXAndY():
	x = max(all_div)
	y_div = []
	common_list = []
	for ele in c_div:
		if c_div[ele] == 2:
			common_list.append(ele)
		elif x % ele != 0:
			y_div.append(ele)
	if len(y_div) == 0:
		y = max(common_list)
	else:
		y = max(common_list) if max(common_list) > max(y_div) else max(y_div)
	return (x, y)
c_div = dict()
all_div = list(map(int, input().split(' ')))
for val in all_div:
	if val in c_div:
		c_div[val] = 2
	else:
		c_div[val] = 1
(x, y) = findXAndY()
print(x, y)


int(input())
ar = [int(i) for i in input().split()]
x = max(ar)
for i in range(1, x + 1):
	if x % i == 0:
		ar.remove(i)
print(x, max(ar))


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	n = int(input())
	a = list(map(int, input().split()))
	sa = sorted(a)
	x = sa[0] * sa[-1]
	d = []
	for i in range(1, int(math.sqrt(x)) + 1):
		if x % i == 0:
			d.append(i)
			if i * i != x:
				d.append(x // i)
	if len(d) == 1:
		print(1, 1)
		return
	dic = collections.Counter(sa)
	y = 1
	for i in range(n - 2, -1, -1):
		if x % sa[i] != 0 or dic[sa[i]] > 1:
			y = y * sa[i]
			break
	print(x, y)
main()


import sys
n = int(sys.stdin.readline())
d = sys.stdin.readline()[:-1].split()
d = [int(x) for x in d]
d.sort()
maxNum = max(d)
last = 0
for i in range(len(d) - 1, 0, -1):
	if last != d[i]:
		if maxNum % d[i] == 0:
			last = d[i]
			(d[i], d[-1]) = (d[-1], d[i])
			del d[-1]
print(maxNum, max(d))


a = int(input())
b = list(map(int, input().split()))
d = max(b)
for i in range(1, d + 1):
	if d % i == 0:
		tes = b.index(i)
		b[tes] = 1
print(str(d) + ' ' + str(max(b)))


d = int(input())
l = sorted(list(map(int, input().split())))
if l[-1] == l[-2]:
	print(l[-1], l[-2])
else:
	(a, f) = (l[-1], 0)
	for x in range(d - 1):
		if l[x] != l[x + 1] and len(set(l[x:])) == d - x:
			b = l[x]
			break
	for y in range(d - 2, x - 1, -1):
		if a % l[y] != 0:
			b = l[y]
			break
	print(b, a)


from sys import stdin
from math import sqrt

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
a = linput()
y = max(a)
i = 0
for i in range(1, int(sqrt(y)) + 1):
	if y % i == 0:
		try:
			a.remove(i)
		except:
			pass
		try:
			if i != y // i:
				a.remove(y // i)
		except:
			pass
x = max(a)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
sa = set(a)
a.sort()
i = a[-1]
ii = 1
j = 0

def factors(a):
	f = set()
	i = 1
	while i * i <= a:
		if a % i == 0:
			f.add(i)
			f.add(a // i)
		i += 1
	return f

def mul(a):
	ans = 1
	for i in a:
		ans *= i
	return ans
aa = mul(a)
ans = mul(factors(i))
for j in range(2, n):
	k = a[-j]
	ff = factors(k)
	ch = 0
	for m in ff:
		if m in sa:
			ch += 1
	if ch == len(ff):
		a1 = mul(ff)
		if aa // a1 == ans:
			ii = a[-j]
			break
print(i, ii)


n = int(input())
l = list(list(map(int, input().split())))
l = sorted(l)
one_element = l[-1]
doubles = []
for i in l:
	if len(list(filter(lambda x: x == i, l))) > 1:
		if i not in doubles:
			doubles.append(i)
			l.remove(i)
l = list(filter(lambda x: one_element % x != 0, l))
try:
	ans = l[-1]
except:
	ans = doubles[-1]
print(one_element, ans)


x = int(input())
s = sorted(list(map(int, input().split())))
print(max(s), end=' ')
j = max(s)
del s[-1]
l = 0
for n in range(x - 1):
	if j % s[n] == 0 and s[n] != l and (s[n] != j):
		l = s[n]
		s[n] = 0
print(max(s))


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
from itertools import combinations
from sys import stdin
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())
n = intIn()
d = listIn()
lia = []
lib = []
di = {}
for i in range(n):
	if d[i] not in di:
		di[d[i]] = 1
	else:
		di[d[i]] += 1
d = sorted(set(d))
d = d[::-1]
n = len(d)
lia = [d[0]]
if len(set(di.values())) == 1:
	print(max(d), max(d))
else:
	for i in range(n):
		if di[d[i]] == 2:
			lia.append(d[i])
			lib.append(d[i])
		elif lia[0] % d[i] == 0:
			lia.append(d[i])
		else:
			lib.append(d[i])
	print(max(lia), max(lib))


n = int(input())
a = list(map(int, input().split()))
t = max(a)
b = []
a.sort()
for i in range(n):
	if a.count(a[i]) > 1 or t % a[i] != 0:
		b.append(a[i])
		a[i] = -1
print(t, max(b))


t = int(input())
d = list(map(int, input().split()))
l1 = []
l2 = []
d.sort(reverse=True)
for i in d:
	if i not in l1 and max(d) % i == 0:
		l1.append(i)
	else:
		l2.append(i)
print(max(l1), max(l2))


n = int(input())
d = [int(x) for x in input().split()]
d.sort()
d1 = []
s = set()
a = d[n - 1]
for x in d:
	if not x in s:
		if a % x == 0:
			s.add(x)
			continue
		else:
			d1.append(x)
	else:
		d1.append(x)
d1.sort()
l = len(d1)
if l == 0:
	b = a
else:
	b = d1[l - 1]
print(a, b)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	try:
		f = open('input' + str(inId) + '.txt', 'r')
		sys.stdin = f
	except Exception:
		dprint('invalid input file')
if outId > 0:
	dprint('use output', outId)
	try:
		f = open('stdout' + str(outId) + '.txt', 'w')
		sys.stdout = f
	except Exception:
		dprint('invalid output file')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
za = getIntList()
za.sort()
dprint(za)
for i in range(1, N):
	if za[i - 1] == za[i]:
		t = za[i]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for x in reversed(za):
	if x % t != 0:
		continue
	if gcd(x, za[-1]) != t:
		continue
	ok = True
	for y in za:
		if x % y == 0 or za[-1] % y == 0:
			pass
		else:
			ok = False
			break
	if ok:
		print(x, za[-1])
		break


n = int(input())
D = list(map(int, input().split()))
D.sort()
y = D[-1]
from collections import Counter
C = Counter(D)

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
dy = make_divisors(y)
for d in dy:
	C[d] -= 1
max_ = -1
for (k, v) in C.items():
	if v > 0:
		max_ = max(max_, k)
print(max_, y)


from sys import stdin
input = stdin.buffer.readline
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if arr[i] in d:
		d[arr[i]].append(i)
	else:
		d[arr[i]] = [i]
maxx = max(arr)
l = []
for i in range(1, maxx + 1):
	if maxx % i == 0:
		l.append(i)
for x in l:
	d[x].pop()
maxx1 = 0
for i in d.keys():
	if len(d[i]) != 0:
		maxx1 = max(maxx1, i)
print(maxx, maxx1)


from math import gcd
from sys import stdin

def myfunction():
	pass
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
p = dict()
if n == 2:
	print(arr[0], arr[1])
	exit()
for i in arr:
	if i in p:
		p[i] += 1
	else:
		p[i] = 1
b = []
for i in p:
	if p[i] == 2:
		b.append(i)
arr.sort(reverse=True)
for i in range(1, n):
	if gcd(arr[i], arr[0]) in b:
		f_a = arr[0]
		f_b = arr[i]
		break
print(f_a, f_b)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def ncr(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]

def divi(n):
	i = 1
	l = []
	while i <= math.ceil(int(n ** 0.5)):
		if n % i == 0:
			l.append(i)
			if n // i != i:
				l.append(n // i)
		i += 1
	return l
n = int(input())
l = list(numIN())
l.sort()
for i in range(n):
	for j in range(n):
		if i != j:
			if list(sorted(divi(l[i]) + divi(l[j]))) == l:
				print(l[i], l[j])
				exit(0)


import math
n = input()
l = list(map(int, input().split()))
a = max(l)
for i in range(1, a + 1):
	if a % i == 0:
		l.remove(i)
print('{0} {1}'.format(a, max(l)))


a = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
t = b[0]
g = []
i = 0
while i != len(b):
	if t % b[i] != 0 and b.count(b[i]) == 1:
		g.append(b[i])
	elif b.count(b[i]) == 2:
		g.append(b[i])
		b.remove(b[i])
	i += 1
if len(g) == 0:
	print(b[0], b[1])
else:
	g.sort(reverse=True)
	k = g[0]
	print(t, k)


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
l.sort()
first = l[-1]
for i in range(n - 1, 0, -1):
	if l[i] == l[i - 1]:
		second = l[i]
		break
	elif first % l[i] != 0:
		second = l[i]
		break
print(first, second)


n = int(input())
ls = list(map(int, input().split()))
ls.sort()
p = ls[n - 1]
ps = [0] * (p // 2 + 1)
i = 0
while ls[i] <= p // 2:
	if not p % ls[i] and ps[ls[i]] == 0:
		ps[ls[i]] = 1
		ls[i] = 0
	i += 1
ls.sort()
print(p, ls[n - 2])


def factors(l):
	m = max(l)
	for i in range(1, int(m ** 0.5) + 1):
		if m % i == 0:
			if i in l:
				l.remove(i)
			if m // i in l and m // i != i:
				l.remove(m // i)
	return max(l)
n = int(input())
l = list(map(int, input().split()))
if len(l) == 2:
	print(*l)
else:
	print(max(l), end=' ')
	print(factors(l))


n = int(input())
a = list(map(int, input().split()))
h = max(a)
f = (h + 1) * [0]
for i in range(n):
	f[a[i]] += 1
b = []
for i in range(1, h + 1):
	if f[i] > 1:
		b.append(i)
for i in range(n):
	if h % a[i] == 0:
		a[i] = -1
print(h, max(max(b), max(a)))


n = int(input())
lst = list(map(int, input().split()))
dct = {}
for i in lst:
	dct[i] = dct.get(i, 0) + 1
num_1 = max(lst)
for i in dct:
	if num_1 % i == 0:
		dct[i] -= 1
lar = 0
for i in dct:
	if dct[i] != 0 and i > lar:
		lar = i
print(num_1, lar)


n = int(input())
li = list(map(int, input().split(' ', n)[:n]))
x = max(li)
li2 = []
li3 = []
for i in range(n):
	if x % li[i] != 0:
		li2.append(li[i])
	elif li.count(li[i]) > 1:
		li3.append(li[i])
if len(li2) != 0:
	y = max(li2)
elif len(li3) != 0:
	y = max(li3)
else:
	y = 1
print(x, y)


from math import *

def fact(n):
	li = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			li.append(i)
			if i != n / i:
				li.append(int(n / i))
	li.sort()
	return li
n = int(input())
li1 = list(map(int, input().split()))
ab = max(li1)
li2 = fact(ab)
li3 = list((i for i in li1 if i not in li2))
li4 = list(set(list((i for i in li1 if li1.count(i) == 2))))
li3.extend(li4)
print(ab, max(li3))


n = int(input())
divs = list(map(lambda x: int(x), input().split()))
x = max(divs)
xdivs = []
for d in divs:
	if not x % d and d not in xdivs:
		xdivs.append(d)
for xd in xdivs:
	divs.remove(xd)
y = max(divs)
print(x, y)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)
d = Counter(l)
x = l[0]
y = 0
for i in range(1, n):
	if x % l[i] != 0:
		y = l[i]
		break
if y == 0:
	for i in range(1, n):
		if d[l[i]] == 2:
			y = l[i]
			break
print(x, y)


def printDivisors(n):
	i = 1
	d = []
	while i <= n:
		if n % i == 0:
			d.append(i)
		i = i + 1
	return d
n = int(input())
div = list(map(int, input().split()))
x = max(div)
div_x = printDivisors(x)
for i in div_x:
	if i in div:
		div.remove(i)
y = max(div)
print(x, y)


n = int(input())
lst = [int(i) for i in input().split()]
max1 = max(lst)
lst2 = []
lst3 = []
for i in lst:
	if max1 % i == 0 and i not in lst3:
		lst3.append(i)
	else:
		lst2.append(i)
print(max1, max(lst2))


import sys, collections
from heapq import heappop, heappush
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
n = inp()
d = inpl()
d.sort()
res1 = d[-1]
c = collections.Counter(d)
for x in make_divisors(res1):
	c[x] -= 1
res2 = 0
for key in c.keys():
	if c[key] > 0:
		res2 = max(res2, key)
print(res1, res2)


from math import sqrt

def num_div_set2(N):
	s = {1, N}
	end = int(sqrt(N)) + 1
	for i in range(2, end + 1):
		if N % i == 0:
			s.add(i)
			s.add(N // i)
	return s
N = int(input())
dN = sorted(map(int, input().split()))
l1 = sorted(num_div_set2(max(dN)))
for i in range(len(l1)):
	for j in range(N):
		if l1[i] == dN[j]:
			dN[j] = -1
			break
print(l1[-1], max(dN))


n = int(input())
lista = [int(x) for x in input().split()]
maxi = 0
id = 0
for i in range(0, len(lista)):
	if maxi < lista[i]:
		maxi = lista[i]
		id = i
lista[id] = -1
another = []
another.append(maxi)
print(maxi, end=' ')
maxi2 = -1
for i in range(0, len(lista)):
	if maxi % lista[i] == 0 and lista[i] not in another:
		another.append(lista[i])
		lista[i] = -1
maxi2 = max(lista)
if maxi2 == -1:
	print(maxi)
else:
	print(maxi2)


def func(nums):
	nums.sort()
	s1 = set()
	s2 = set()
	max1 = None
	max2 = None
	for i in reversed(nums):
		if len(s1) == 0:
			s1.add(i)
			max1 = i
		elif i not in s1 and max1 % i == 0:
			s1.add(i)
		else:
			if len(s2) == 0:
				max2 = i
			s2.add(i)
	print(max1, max2)
n = int(input())
nums = [int(i) for i in input().split()]
func(nums)


n = int(input())
lul = input().split()
lul = [int(i) for i in lul]
lul.sort(reverse=True)
x = lul[0]
for i in range(n):
	if x % lul[i] != 0 or lul[i] == lul[i + 1]:
		y = lul[i]
		break
print(str(x) + ' ' + str(y))


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
(x, b, c, prod) = (max(a), [], [], 0)
for i in range(len(a)):
	if x % a[i] != 0:
		b.append(a[i])
for i in range(1, len(a)):
	if a[i] == a[i - 1]:
		c.append(a[i])
if len(b) != 0:
	y = max(b)
else:
	y = max(c)
print(x, y)


from math import gcd
N = int(input())
ar = [int(x) for x in input().split()]
ar.sort()
a = ar[-1]
br = []
for i in range(N):
	if i > 0 and ar[i] == ar[i - 1]:
		br.append(ar[i])
	elif a % ar[i] != 0:
		br.append(ar[i])
b = 1
for i in br:
	b = b * int(i) // gcd(b, i)
print(a, b)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
ma = arr[n - 1]
for i in range(1, ma // 2 + 1):
	if ma % i == 0:
		arr.remove(i)
print(ma, end=' ')
arr.remove(ma)
print(max(arr))


def B():
	n = int(input())
	s = [int(x) for x in input().split()]
	x = max(s)
	for d in range(1, x + 1):
		if x % d == 0:
			s.remove(d)
	y = max(s)
	print(x, y)
B()


from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
lst = Counter(a)
freq = 0
for i in sorted(lst):
	if lst[i] == 2:
		freq = max(freq, i)
mn = 0
for i in range(n):
	if a[-1] % a[i]:
		mn = max(mn, a[i])
if mn != 0:
	print(a[-1], mn)
else:
	print(a[-1], freq)


n = int(input())
t = list(map(int, input().rstrip().split()))
t.sort()
k = t[n - 1]
c = t[n - 2]
for i in range(n - 1):
	if k % t[i] == 0 and t[i] != t[i + 1]:
		t[i] = 0
t[n - 1] = 0
if max(t) != 0:
	c = max(t)
print(k, end=' ')
print(c)


n = int(input())
lst = list(map(int, input().split()))
y = max(lst)
for i in range(1, int(y ** 0.5) + 1):
	if y % i == 0 and i != y // i:
		del lst[lst.index(i)]
		del lst[lst.index(y // i)]
	elif y % i == 0 and i == y // i:
		del lst[lst.index(i)]
x = max(lst)
print(x, y)


n = int(input())
deli = list(map(int, input().split()))
p = max(deli)
v = 1
deli.sort()
i = n - 1
flag = 0
while p % deli[i] == 0 and i > -1:
	i -= 1
	if deli[i] == deli[i + 1]:
		print(p, deli[i])
		flag = 1
		break
if flag == 0:
	if i == -1:
		print(p, v)
	else:
		print(p, deli[i])


n = int(input())
A = [int(i) for i in input().split()]
mx = max(A)
B = A[:]
done = dict()
for i in A:
	if mx % i == 0:
		if i not in done:
			done[i] = 1
			B.remove(i)
		elif done[i] == 1:
			continue
mn = 1
mn = max(B)
print(mx, mn)


import math
n = int(input())
l = list(map(int, input().split()))
maxint = max(l)
root = int(math.sqrt(maxint))
for i in range(1, root + 1):
	if maxint % i == 0:
		j = maxint // i
		if j == i:
			l.remove(i)
		else:
			l.remove(i)
			l.remove(j)
print(maxint, max(l))


n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
l = []
for i in li:
	if li.count(i) == 2:
		l.append(i)
l = list(set(l))
l.sort(reverse=True)
for i in li[1:]:
	if li[0] % i != 0:
		print(li[0], i)
		exit(0)
if li[0] % li[1] != 0:
	print(li[0], li[1])
elif len(l) == 1:
	if li[0] % li[1] == 0:
		print(1, max(li))
	else:
		print(li[0], li[1])
elif len(li) == 4:
	print(li[0], li[1])
elif len(l) >= 2:
	l.sort(reverse=True)
	print(l[0], max(li))


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
d = {}
for i in l:
	d[i] = 0
for i in l:
	d[i] += 1
ans1 = max(l)
for i in range(ans1, 0, -1):
	if ans1 % i == 0:
		d[i] -= 1
ans2 = -1
for i in d:
	if d[i] > 0:
		if i > ans2:
			ans2 = i
print(str(ans1) + ' ' + str(ans2))


n = int(input())
a = list(map(int, input().split(' ')))
a = sorted(a)
x = a[-1]
div = [1]
i = 1
new = []
dic = {}
for i in range(n):
	if x % a[i] == 0:
		if a[i] not in dic:
			dic[a[i]] = 1
			a[i] = 0
y = max(a)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a.sort()
l = max(a)
a.reverse()
b = set()
b.add(l)
a = a[1:]
for i in a:
	if l % i == 0:
		if i in b:
			p = i
			break
		else:
			b.add(i)
	else:
		p = i
		break
print(l, p)


from collections import deque
from math import sqrt

def solve(n):
	res = deque()
	i = 1
	while i <= int(sqrt(n)):
		if n % i == 0:
			if n // i == i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
		i += 1
	return res
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
for i in range(n):
	for j in range(n):
		k1 = solve(l[i])
		k2 = solve(l[j])
		k3 = k1 + k2
		if sorted(k3) == sorted(l):
			print(l[i], l[j])
			exit(0)


input()
l = list(map(int, input().split()))
M = max(l)
M2 = 0
l2 = []
for i in range(1, M + 1):
	if M % i == 0:
		l2.append(i)
l2 = set(l2)
for i in l:
	if i in l2:
		l2.remove(i)
	else:
		M2 = max(M2, i)
print(M, M2)


n = int(input())
l = input()
k = 0
k1 = 1
l1 = [int(m) for m in l.split()]
l2 = [int(m) for m in l.split()]
l3 = []
for i in l1:
	if k < i:
		k = i
for i in l1:
	if k % i == 0 and (not i in l3):
		l2.remove(i)
	l3.append(i)
for i in l2:
	if k1 < i:
		k1 = i
print(k, k1)


n = int(input())
from collections import Counter

def divisors(x):
	d = 1
	ans = []
	while d * d < x:
		if x % d == 0:
			ans.append(d)
			ans.append(x // d)
		d += 1
	if d * d == x:
		ans.append(d)
	return ans
divs = [int(x) for x in input().split()]
dset = Counter(divs)
x = max(divs)
dx = divisors(x)
for el in dx:
	dset[el] -= 1
y = 0
for el in dset:
	if dset[el] != 0 and el > y:
		y = el
print(x, y)


import math
n = int(input())
L = list(map(int, input().split()))
L.sort()
dict = {}
dict[L[0]] = 1
for i in range(1, len(L)):
	if L[i] != L[i - 1]:
		dict[L[i]] = 1
	else:
		dict[L[i]] += 1
maxi = 1
for e in dict.keys():
	if dict[e] == 2 and e > maxi:
		maxi = e
M = list(dict.keys())
N = [0] * len(M)
for i in range(0, len(M)):
	for j in range(0, len(M)):
		if M[i] % M[j] == 0:
			N[i] += 1
for i in range(0, len(N)):
	for j in range(0, i + 1):
		if N[i] + N[j] == n and math.gcd(M[i], M[j]) == maxi:
			print(str(M[i]) + ' ' + str(M[j]))
			break


n = int(input())
divs = list(map(int, input().split(' ')))
x = max(divs)
do = []
for (i, d) in enumerate(divs):
	if x % d == 0 and d not in do:
		do.append(d)
		divs[i] = 0
y = max(divs)
print(str(x) + ' ' + str(y))


n = int(input())
a = list(map(int, input().split()))
x = max(a)
b = []
c = []
for i in range(n):
	if x % a[i] == 0:
		if a[i] in b:
			c.append(a[i])
		else:
			b.append(a[i])
	else:
		c.append(a[i])
print(x, max(c))


q = int(input())
w = [int(x) for x in input().split()]
n = max(w)
a = []
b = []
for i in w:
	if n % i == 0 and i not in a:
		a.append(i)
	else:
		b.append(i)
print(n, max(b))


n = int(input())
a = list(map(int, input().split()))
check = n * [False]
a.sort()
x = 1
m = 0
y = a[n - 1]
check[0] = True
for i in range(1, n):
	if (check[i - 1] == False or a[i - 1] != a[i]) and y % a[i] == 0:
		check[i] = True
for i in range(n):
	if check[i] == False and m < a[i]:
		x = a[i]
print(x, y)


n = int(input())
l = list(map(int, input().split(' ')))
y = max(l)
if l.count(y) == 1:
	l.remove(y)
	x = max(l)
	while y % x == 0 and l.count(x) == 1:
		l.remove(x)
		x = max(l)
	print(x, y)
else:
	print(y, y)


n = int(input())
v = input('')
v = v.split()
for i in range(len(v)):
	v[i] = int(v[i])
v.sort()
y = v[-1]
v.remove(v[-1])
for i in range(1, y):
	if y % i == 0:
		v.remove(i)
v.sort()
x = v[-1]
print(x, y)


input()
lst = list(map(int, input().split()))
lst.sort()
d1 = lst[-1]
for k in lst:
	if lst.count(k) > 1 or d1 % k:
		d2 = k
print(d1, d2)


n = int(input())
a = [int(i) for i in input().split()]
k = max(a)
b = []
c = set()
for i in range(n):
	if k % a[i] == 0 and a[i] not in c:
		c.add(a[i])
	else:
		b.append(a[i])
print(k, max(b))


def solve(arr, n):
	dup = {}
	arr.sort()
	x = arr[-1]
	arr.pop(-1)
	i = len(arr) - 1
	while i > -1:
		if x == arr[i]:
			i -= 1
			continue
		elif x % arr[i] == 0:
			if arr[i] not in dup:
				dup[arr[i]] = 1
				arr.pop(i)
		i -= 1
	y = arr[-1]
	print(x, y)

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	solve(arr, n)
main()


x = int(input())
y = list(map(int, input().split()))
y.sort()
m = max(y)
for i in set(y):
	if m % i == 0:
		y.remove(i)
print(m, y[-1])


(z, w, m) = (input, int, sorted)
n = int(z())
l = list(map(int, z().split()))
f = max(l)
for i in range(1, f + 1):
	if f % i == 0:
		l.remove(i)
print(f, max(l))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = arr[n - 1]
print(a, max((i for i in arr if a % i or arr.count(i) > 1)))


n = int(input())
a = sorted(list(map(int, input().split())))
s = a[-1]
if a.count(a[-1]) == 2:
	print(a[-1], a[-1])
	exit()
for i in range(len(a) - 1, -1, -1):
	if s % a[i] != 0 or i == 0 or a.count(int(a[i])) == 2:
		print(s, a[i])
		exit()


import math
n = eval(input())
array = list(map(int, input().split()))
array.sort()
x = array[-1]
arr = []
max1 = -1
for i in array:
	if x % i != 0 or (x % i == 0 and array.count(i) == 2):
		max1 = max(max1, i)
y = max1
print(x, y)


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
a.sort()
a.reverse()
for i in range(n - 1):
	if mx % a[i] != 0:
		mn = int(a[i])
		break
	if mx % a[i] == 0 and a[i] == a[i + 1]:
		mn = int(a[i])
		break
print(mx, mn)


n = int(input())
s = input().split()
for q in range(len(s)):
	s[q] = int(s[q])

def nod(a, b):
	if b == 0:
		return a
	else:
		return nod(b, a % b)
a = 0
for i in s:
	flag = False
	for j in s:
		if i == j:
			if flag == False:
				flag = True
			else:
				if i > a:
					a = i
				break
b = max(s)
c = 0
for q in s:
	if nod(b, q) == a:
		if q > c:
			c = q
print('{} {}'.format(b, c))


n = int(input())
numeros = input().split()
numeros = [int(x) for x in numeros]
num1 = [max(numeros)]
numeros.remove(max(numeros))
num2 = []
for i in numeros:
	if i not in num1 and num1[0] % i == 0:
		num1.append(i)
	else:
		num2.append(i)
print(num1[0], max(num2))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
c = l[0]
d = 0
p = 0
for i in range(n):
	if c % l[i] != 0:
		d = l[i]
		break
for i in range(n):
	if l.count(l[i]) > 1:
		p = l[i]
		break
if d == 0:
	print(l[0], p)
else:
	print(l[0], d)


input()
sorted_list = sorted(map(int, input().split()), reverse=True)
used_list = [False for _ in range(len(sorted_list))]
used_dict = {}
first = sorted_list[0]
used_list[0] = True
print(first)
for (index, value) in enumerate(sorted_list):
	if first % value == 0 and value not in used_dict:
		used_list[index] = True
		used_dict[value] = True
for (index, value) in enumerate(used_list):
	if not value:
		print(sorted_list[index])
		break


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
x = a[-1]
past = 0
for i in range(n):
	if a[-1] % a[i] == 0 and past != a[i]:
		past = a[i]
		a[i] = 0
a.sort()
print(x, a[-1])


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
p = a[0]
cur = p
q = 1
for i in range(1, n):
	if a[i] == cur or not p % a[i] == 0:
		q = a[i]
		break
	else:
		cur = a[i]
print(p, q)


def get_divisor_list(num):
	result = []
	for i in range(1, num + 1):
		if num % i == 0:
			result.append(i)
	return result
q = int(input())
input_dividor_list = list(map(int, input().split()))
b = max(input_dividor_list)
b_divisor_list = get_divisor_list(b)
for e in b_divisor_list:
	input_dividor_list.remove(e)
a = max(input_dividor_list)
print('{} {}'.format(str(a), str(b)))


n = int(input())
a = list(map(int, input().split(' ')))
print(*[max(a)] + [max(list(map(lambda x: x // x if max(a) % x == 0 and a.count(x) == 1 else x, a)))])


n = int(input())
array = list(map(int, input().split()))
a = max(array)
for t in range(1, a + 1):
	if a % t == 0:
		array.remove(t)
b = max(array)
print('{} {}'.format(a, b))


input()
d = list(map(int, input().split()))
x = max(d)
print(x, max((y for y in d if x % y or d.count(y) > 1)))


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
x = arr[n - 1]
y = 1
for i in range(n - 1, -1, -1):
	if x % arr[i] != 0:
		y = arr[i]
		break
	if x % arr[i] == 0 and arr[i] == arr[i - 1]:
		y = arr[i]
		break
print(str(x) + ' ' + str(y))


n = int(input())
mas = list(map(int, input().split()))
mas.sort()
mas = [-1] + mas
x = mas[-1]
i = -1
while i > -n - 1:
	if x % mas[i] == 0:
		if mas[i - 1] == mas[i]:
			print(x, mas[i])
			break
	else:
		print(x, mas[i])
		break
	i -= 1


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = max(a)
(b, t) = ([], float('inf'))
while a != []:
	k = a.pop()
	if k == t:
		b.append(k)
		continue
	if m % k == 0:
		t = k
	if m % k != 0:
		b.append(k)
		t = k
print(m, max(b))


from fractions import gcd
from collections import Counter

def lcm(a, b):
	return a * b // gcd(a, b)
input()
arr = list(map(int, input().split()))
count = Counter(arr)
a = max(arr)
b = 1
for x in count:
	if a % x != 0 or count[x] > 1:
		b = lcm(b, x)
print(str(a) + ' ' + str(b))


n = int(input())
d = sorted(list(map(int, input().split())))
x = d[-1]
for i in range(1, x + 1):
	if x % i == 0:
		d.remove(i)
print(x, d[-1])


from collections import Counter
n = int(input())
D = list(map(int, input().split()))
cc = Counter(D)
x = max(D)
if cc[x] == 2:
	print('{x} {x}'.format(x=x))
	exit(0)
for d in cc:
	if x % d == 0:
		cc[d] -= 1
cc[x] = 0
y = max((f for f in cc if cc[f]))
print('{x} {y}'.format(x=x, y=y))


n = int(input())
val = list(map(int, input().split()))
a = max(val)
val.sort()
qtd = []
for i in range(a + 1):
	qtd.append(0)
for i in range(n):
	qtd[val[i]] += 1
y = 0
for i in range(n):
	if a % val[i] == 0:
		if qtd[val[i]] > 1:
			y = max(y, val[i])
	else:
		y = max(val[i], y)
print(a, y)


n = int(input())
d = list(map(int, input().split()))
x = max(d)
x_div = []
duplicate = []
for i in range(len(d)):
	if x % d[i] == 0:
		x_div.append(d[i])
		if d.count(d[i]) == 2:
			if d[i] not in duplicate:
				duplicate.append(d[i])
xDiv = []
for i in x_div:
	if i not in xDiv:
		xDiv.append(i)
yDiv = duplicate
for i in range(len(d)):
	if d[i] not in xDiv:
		yDiv.append(d[i])
y = max(yDiv)
print(str(x) + ' ' + str(y))


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
last = 1000007
b = a
for i in range(n - 1, -1, -1):
	if a % l[i] != 0 or l[i] == last:
		b = l[i]
		break
	last = l[i]
print(a, b)


n = int(input())
a = list(map(int, input().split()))
f = max(a)
j = int(f ** 0.5)
d = []
c = []
for i in range(1, j + 1):
	if f % i == 0:
		d.append(i)
		a[a.index(i)] = -1
		if i * i != f:
			d.append(int(f / i))
			a[a.index(int(f / i))] = -1
print(f, max(a))


n = int(input())
num = list(map(int, input().split()))
num.sort()
for i in range(n - 1, 0, -1):
	if num[n - 1] % num[i] != 0 or num[i] == num[i - 1]:
		print(num[i], num[n - 1], sep=' ')
		break


a = int(input())
b = list(map(int, input().split()))
f = set(b)
max_1 = max(b)
for i in f:
	if max_1 % i == 0:
		b.remove(i)
print(max_1, max(b))


n = int(input())
p = list(map(int, input().split()))
p.sort(reverse=True)
for elem in p:
	if p[0] % elem != 0 or p.count(elem) > 1:
		print(p[0], elem)
		break


def divisors(arr):
	a = arr[0]
	temp = []
	for i in arr:
		if a < i:
			a = i
	for i in arr:
		if a % i == 0 and i not in temp:
			temp.append(i)
	for i in temp:
		arr.remove(i)
	b = arr[0]
	for i in arr:
		if b < i:
			b = i
	return (a, b)
n = int(input())
arr = list(map(int, input().split()))
(a, b) = divisors(arr)
print(str(a) + ' ' + str(b))


visited = [False for i in range(129)]

def factors(x):
	fac = []
	for i in range(1, x + 1):
		if x % i == 0:
			fac.append(i)
	return fac
n = int(input())
arr = list(map(int, input().split()))
first = max(arr)
f = factors(first)
for each in f:
	found = False
	for i in range(n):
		if arr[i] == each:
			visited[i] = True
			found = True
			break
		if found == True:
			break
m = -1
for i in range(n):
	if visited[i] == False:
		m = max(m, arr[i])
print(str(first) + ' ' + str(m))


n = int(input())
d = list(map(int, input().split()))[:n]
m = []
mx = max(d)
shit = []
for i in range(len(d)):
	if mx % d[i] != 0:
		m.append(d[i])
for i in range(len(d)):
	if d.count(d[i]) == 2:
		shit.append(d[i])
if mx in shit:
	shit.remove(mx)
if len(m) > 0:
	print(mx, max(m))
elif d.count(mx) == 2:
	print(mx, mx)
else:
	print(mx, max(shit))


n = int(input())
l = [int(i) for i in input().split()]
q = max(l)
for i in range(1, q // 2 + 1):
	if i in l and q % i == 0:
		l.remove(i)
l.remove(q)
print(q, max(l))


def main():
	n = int(input())
	list = [int(x) for x in input().split()]
	list.sort(reverse=True)
	big = list[0]
	nlist = []
	for i in range(1, n):
		if list[i - 1] == list[i]:
			nlist.append(list[i])
	for i in range(1, n):
		if big % list[i] == 0:
			if list[i] in nlist:
				break
		else:
			break
	print(list[0], list[i])
main()


n = int(input())
a = sorted([int(x) for x in input().split()])
s1 = a[-1]
s1a = []
s2a = []
for i in a:
	if s1 % i == 0:
		if i not in s1a:
			s1a.append(i)
		else:
			s2a.append(i)
	elif i not in s2a:
		s2a.append(i)
	else:
		s1a.append(i)
s2 = s2a[-1]
print(s1, s2)


input()
a = [int(x) for x in input().split()]
x = max(a)
s = {i for i in range(1, x + 1) if x % i == 0}
y = 0
for z in a:
	if z in s:
		s.remove(z)
	elif z > y:
		y = z
print(x, y)


n = int(input())
l = [int(i) for i in input().split()]
a = max(l)
l1 = []
for i in l:
	if a % i == 0:
		if i not in l1:
			l1.append(i)
for i in l1:
	l.remove(i)
b = max(l)
print(a, b)


n = int(input())
d = list(map(int, input().split()))
d.sort()
xd = []
y = max(d)
x = 1
for i in range(1, n):
	if y % d[i] == 0:
		if d[i - 1] == d[i]:
			xd.append(d[i])
	else:
		xd.append(d[i])
x = max(xd)
print(x, y)


import sys
I = sys.stdin.readline
n = int(input())
arr = list(map(int, I().split()))
s = sorted(arr)

def cal(n, p):
	lis_n = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			if i == n // i:
				lis_n.append(i)
			else:
				lis_n.append(i)
				lis_n.append(n // i)
	lis_p = []
	for i in range(1, int(p ** 0.5) + 1):
		if p % i == 0:
			if i == p // i:
				lis_p.append(i)
			else:
				lis_p.append(i)
				lis_p.append(p // i)
	return sorted(lis_n + lis_p)
arr.sort(reverse=True)
for i in range(n):
	for j in range(i + 1, n):
		if cal(arr[i], arr[j]) == s:
			print(arr[i], arr[j])
			break


input()
list = sorted(map(int, input().split()), reverse=1)
div1 = list[0]
for i in list:
	if div1 % i != 0 or list.count(i) > 1:
		print(div1, i)
		break


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
flag = 0
d = {l[-1]: True}
for i in range(len(l) - 2, -1, -1):
	if a % l[i] != 0:
		print(a, l[i])
		flag = 1
		break
	else:
		try:
			if d[l[i]]:
				print(a, l[i])
				flag = 1
				break
		except:
			d[l[i]] = True


N = int(input())
L = list(map(int, input().split()))
X = []
X += [max(L)]
L.pop(L.index(X[0]))
for i in range(N - 1):
	if X[0] % L[i] == 0 and X.count(L[i]) == 0:
		X += [L[i]]
		L[i] = 0
print(max(X), max(L))


input()
(*l,) = sorted(map(int, input().split()))
f = l[-1]
d = {i: l.count(i) for i in set(l)}
if 1 not in d.values():
	print(f, f)
else:
	del d[f]
	for i in range(1, f // 2 + 1):
		if not f % i:
			d[i] -= 1
	d = {i: d[i] for i in d.keys() if d[i]}
	print(f, max(d.keys()))


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans1 = a[n - 1]
print(ans1, end=' ')
flag = True
for i in range(n - 2, -1, -1):
	if ans1 % a[i] != 0:
		print(a[i])
		flag = False
		break
	elif a[i] == a[i + 1]:
		print(a[i])
		flag = False
		break
if flag:
	print(1)


n = int(input())
a = list(map(int, input().split()))
ch1 = max(a)
nums = set()
for i in range(len(a)):
	if ch1 % a[i] == 0 and a[i] not in nums and (a[i] != -1):
		nums.add(a[i])
		a[i] = -1
print(ch1, max(a))


n = int(input())
d = list(map(int, input().split()))
d.sort()
x = d[-1]
x_d = set()
y_d = []
for i in range(n):
	if x % d[i] == 0 and d[i] not in x_d:
		x_d.add(d[i])
	else:
		y_d.append(d[i])
y_d.sort()
print(x, y_d[-1])


def main():
	input()
	nums = [int(x) for x in input().split()]
	nums.sort()
	a = nums[-1]
	divs = set()
	b = 1
	for n in nums:
		if a % n == 0 and n not in divs:
			divs.add(n)
		else:
			b = max(b, n)
	print(a, b)
main()


import math

def Divisors(n):
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				value = int(i)
				div.append(value)
			else:
				value = int(i)
				value1 = int(n / i)
				div.append(value)
				div.append(value1)
		i = i + 1
a = input()
a = int(a)
if a <= 2:
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	for i in arr:
		print(i, end=' ')
else:
	arr = []
	div = []
	arr = [int(x) for x in input().split()]
	val = max(arr)
	print(val, end=' ')
	Divisors(val)
	for (elm, i) in enumerate(div, start=0):
		if i in arr:
			arr.remove(i)
	arr.sort(reverse=True)
	print(arr[0])


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
x = a[0]
b = set()
for i in a:
	if x % i or i in b:
		print(x, i)
		break
	b.add(i)


n = int(input())
list1 = list(map(int, input().split()))
mx1 = max(list1)
for i in range(1, mx1 + 1):
	if mx1 % i == 0:
		list1.remove(i)
mx2 = max(list1)
print('{} {}'.format(mx1, mx2))


n = int(input())
arr = list(map(int, input().split()))
c_max = max(arr)
a = []
for i in arr:
	if c_max % i == 0 and i not in a:
		a.append(i)
for l in a:
	arr.remove(l)
n_max = max(arr)
print(' '.join([str(c_max), str(n_max)]))


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
x = max(arr)
if arr.count(x) == 2:
	y = x
else:
	arr = sorted(arr)
	i = n - 2
	while i >= 0:
		if arr.count(arr[i]) == 1:
			if x % arr[i] == 0:
				i -= 1
			else:
				break
		else:
			break
	y = arr[i]
print(x, y)


n = int(input())
a = [int(j) for j in input().split()]
m1 = max(a)
b = []
s = set()
s.add(m1)
for i in range(1, int(m1 / 2) + 1):
	if m1 % i == 0:
		s.add(i)
for i in a:
	if i in s:
		s.remove(i)
	else:
		b.append(i)
m2 = max(b)
print(m1, m2)


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
	d[i] = 0
for i in a:
	d[i] += 1
k1 = max(d)
for i in d:
	if k1 % i == 0:
		d[i] -= 1
b = []
for i in d:
	if d[i] == 1:
		b.append(i)
k2 = max(b)
print(k1, k2)


n = input()
s = input()
s = s.split(' ')
nums = []
x = 0
for c in s:
	i = int(c)
	x = max(x, i)
	nums.append(i)
s = set()
for i in nums:
	if x % i == 0:
		s.add(i)
for i in s:
	nums.remove(i)
y = max(nums)
print(x, y)


import math
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
x = arr[-1]
gd = 0
arr2 = list(set(arr))
arr2.sort()
for k in arr2:
	if arr.count(k) == 2:
		gd = max(gd, k)
smh = arr2.index(gd)
for kk in range(len(arr2) - 1, smh - 1, -1):
	if math.gcd(arr2[kk], x) == gd:
		print(arr2[kk], x)
		exit()
print(x, x)


n = int(input())
a = [int(x) for x in input().split()]
first = max(a)
divisors = set()
a.remove(first)
divisors.add(first)
for i in range(len(a) - 1, -1, -1):
	test = a[i]
	if first % test == 0 and (not test in divisors):
		a.pop(i)
		divisors.add(test)
second = max(a)
print(str(first) + ' ' + str(second))


from collections import defaultdict
n = int(input())
x = list()
y = input().split()
for i in range(n):
	x.append(int(y[i]))
x.sort()
temp = x[n - 1]
dell = list()
mape = defaultdict(int)
for i in range(n):
	if mape[x[i]] == 1:
		continue
	if temp % int(x[i]) == 0:
		mape[x[i]] = 1
		dell.append(x[i])
for i in range(len(dell)):
	x.remove(dell[i])
x.sort()
print(str(temp) + ' ' + str(x[len(x) - 1]))


from collections import Counter
ndivisors = int(input())
divisors = map(int, input().split(' '))
counter = Counter(divisors)
a = max(counter)
for key in counter:
	if a % key == 0:
		counter[key] -= 1
b = max([_ for _ in counter if counter[_] > 0])
print('{} {}'.format(a, b))


import math
n = int(input())
a = [*map(int, input().split())]
a.sort(reverse=True)
x = a[0]
i = 2
a[0] = 0
while i <= math.sqrt(x):
	if x % i == 0:
		j = 1
		while j < n:
			if a[j] == i:
				a[j] = 0
				j = n + 1
			j = j + 1
		if i * i != x:
			j = 1
			while j < n:
				if a[j] == x / i:
					a[j] = 0
					j = n + 1
				j = j + 1
	i = i + 1
a.sort(reverse=True)
print(x, a[0])


n = int(input())
a = list(map(int, input().split()))
a.sort()
mx = max(a)
b = [mx]
c = []
for i in range(n - 1):
	if a[i] == a[i + 1]:
		b.append(a[i])
		c.append(a[i])
	elif mx % a[i] != 0:
		c.append(a[i])
print(mx, ' ', max(c))


t = int(input())
li = [int(x) for x in input().split()]
b = max(li)
print(b, end=' ')
flag = 0
c = 1
for i in li:
	if c < i and (b % i != 0 or li.count(i) == 2):
		c = i
print(c)


t = int(input())
str1 = [int(x) for x in input().split()]
str1.sort()
num = str1[-1]
temp = 0
if str1[-1] == str1[-2]:
	temp = 1
for i in range(0, len(str1) - 1):
	if str1[i] != 0 and num % str1[i] == 0 and (str1[i + 1] != str1[i]):
		str1[i] = 0
	elif str1[i] == str1[i + 1] and str1[i] != 0 and (num % str1[i] == 0):
		str1[i + 1] = 0
	elif str1[i] == 0:
		continue
	if str1[-1] % num == 0:
		str1[-1] = 0
if temp == 1:
	print(num, num)
else:
	ans = max(str1)
	print(num, ans)


n = int(input())
d = list(map(int, input().split()))
b = sorted(d)[-1]
common = set(filter(lambda x: d.count(x) > 1, d))
div_b = set(filter(lambda x: b % x == 0, d))
div_a = common | set(d) - div_b
print(sorted(div_a)[-1], b)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
x = l[0]
y = 1
p = 'x'
for i in range(1, n):
	if l[i - 1] == l[i]:
		if p == 'x' and y % l[i] == 0:
			pass
		elif p == 'y' and x % l[i] == 0:
			pass
		else:
			y = l[i]
			continue
	elif x % l[i] == 0:
		p = 'x'
	elif y % l[i] == 0:
		p = 'y'
	else:
		y = l[i]
		continue
print(x, y)


import collections
n = int(input())
d = [int(s) for s in input().split()]
counts = collections.Counter(d)
double = [i for (i, c) in counts.items() if c == 2]
n1 = max(d)
nodiv = [i for i in d if n1 % i != 0]
print(n1, max(max(nodiv + [0]), max(double + [0])))


n = int(input())
list1 = sorted(list(map(int, input().split(' '))))
maxi = list1[-1]
list2 = list1[:]
for j in range(1, maxi + 1):
	if not maxi % j:
		list2.remove(j)
print(list2[-1], maxi)


n = input()
d = input()
divisors = d.split(' ')
divisors = list(map(int, divisors))
divisors.sort()
max = divisors[len(divisors) - 1]
previous = -1
for i in range(len(divisors)):
	if max % divisors[i] == 0 and previous != divisors[i]:
		previous = divisors[i]
		divisors[i] = 'X'
divisors = [div for div in divisors if div != 'X']
print(str(max) + ' ' + str(divisors[len(divisors) - 1]))


n = int(input())
d = list(map(int, input().split()))
d.sort()
check = []
x = d[-1]
for i in d:
	if x % i == 0:
		if i not in check:
			check.append(i)
i = 0
while len(check) != 0:
	flag = False
	for i in range(len(check)):
		for j in range(len(d)):
			if check[i] == d[j]:
				check.pop(i)
				d.pop(j)
				flag = True
				break
		if flag:
			break
d.sort()
print(x, d[-1])


n = int(input())
lst = list(map(int, input().split()))
mx = max(lst)
for i in range(1, mx + 1):
	if mx % i == 0:
		lst.remove(i)
print(mx, max(lst))


n = int(input())
a = [int(x) for x in input().split()]
x = max(a)
dx = [x]
a.remove(x)
dy = a[:]
for i in a:
	if x % i == 0 and i not in dx:
		dx.append(i)
		dy.remove(i)
y = max(dy)
print(x, y)


n = int(input())
a = list(map(int, input().split()))
temp = max(a)
d = {}
l = []
for i in range(10001):
	d[i] = 0
for i in a:
	if temp % i == 0 and d[i] == 0:
		d[i] = 1
	else:
		l.append(i)
print(temp, max(l))


t = int(input())
l = list(map(int, input().split()))
l.sort()
for j in range(t - 2, -1, -1):
	if l[-1] % l[j] != 0 or (l[j + 1] == l[j] and l[-1] % l[j] == 0):
		print(l[-1], l[j])
		break


def removeDuplicates(integers):
	newIntegers = []
	duplicates = []
	for integer in integers:
		if integer not in newIntegers:
			newIntegers.append(integer)
		else:
			duplicates.append(integer)
	return (newIntegers, duplicates)

def factorNumber(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def removeNumbersFromFactorList(integers, factors):
	newIntegers = []
	duplicates = []
	for integer in integers:
		if integer not in factors:
			newIntegers.append(integer)
		else:
			duplicates.append(integer)
	return newIntegers

def numbersAreEqual(integers, newIntegers):
	return len(newIntegers) != len(integers) / 2

def findNumbers(integers):
	(newIntegers, duplicates) = removeDuplicates(integers)
	if numbersAreEqual(integers, newIntegers):
		x = newIntegers.pop()
		factorsOfX = factorNumber(x)
		newIntegers = removeNumbersFromFactorList(newIntegers, factorsOfX)
		if len(newIntegers) == 0:
			y = duplicates.pop()
			print(x, y)
		else:
			y = newIntegers.pop()
			print(x, y)
	else:
		x = newIntegers.pop()
		print(x, x)
n = int(input())
integers = sorted(list(map(int, input().split())))
if n == 2:
	print(*integers)
else:
	findNumbers(integers)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
div = []
for i in range(1, x + 1):
	if x % i == 0:
		div.append(i)
i = 0
while i < len(div):
	if div[i] in a:
		a.remove(div[i])
		i += 1
y = max(a)
print(x, y)


n = eval(input(''))
a = input('')
list1 = []
list2 = []
list3 = []
list1 = a.split(' ')
for i in range(0, n):
	list1[i] = int(list1[i])
n1 = max(list1)
for i in range(0, n):
	if n1 % list1[i] == 0 and list1[i] not in list2:
		list2.append(list1[i])
	else:
		list3.append(list1[i])
n2 = max(list3)
print(n1, end=' ')
print(n2, end=' ')


from collections import Counter
n = int(input())
arr = list(map(int, filter(None, input().split(' '))))
arr = sorted(arr)

def get_div(n):
	li = []
	for i in range(1, int(n / 2) + 1):
		if n % i == 0:
			li.append(i)
	li.append(n)
	return li
n1 = arr[-1]
li2 = get_div(n1)
li3 = list((Counter(arr) - Counter(li2)).elements())
n2 = li3[-1]
print(n1, ' ', n2)


n = int(input())
a = sorted(list(map(int, input().split())))
(x, y) = (a[-1], 0)
for i in range(1, n):
	if a[i] == a[i - 1]:
		y = a[i]
for i in a:
	if x % i != 0:
		y = max(y, i)
print(x, y)


a = int(input())
l = list(map(int, input().split()))
flag1 = 0
l.sort()
t = l[-1]
print(t, end=' ')
r = list(set(l))
r.remove(1)
r.sort(reverse=True)
for i in r:
	if t % i == 0:
		j = 1
		l.remove(i)
	elif l[-1] % i != 0:
		print(i)
		flag1 = 1
		break
if flag1 == 0:
	print(l[-1])


n = int(input())
l = input()
d = []
for x in l.split():
	d.append(int(x))
i = 0
r = []
while i < 2:
	x1 = max(d)
	for j in range(1, x1 + 1):
		if x1 % j == 0:
			d.remove(j)
	r.append(x1)
	i = i + 1
for num in r:
	print(num, end=' ')


def divisor(l):
	m = max(l)
	store = []
	i = 0
	while i < len(l):
		if m % l[i] == 0 and l[i] not in store:
			store.append(l.pop(i))
		else:
			i += 1
	n = max(l)
	return (m, n)
n = input()
l = list(map(int, input().split()))
r = divisor(l)
print(r[0], r[1])


n = int(input())
a = list(map(int, input().split()))
x = max(a)
used = [False] * len(a)
divs = set()
for i in range(len(a)):
	if x % a[i] == 0 and a[i] not in divs:
		used[i] = True
		divs.add(a[i])
y = -1
for i in range(len(a)):
	if not used[i]:
		y = max(y, a[i])
print(f'{x} {y}')


from sys import stdin
n = int(stdin.readline().strip())
d = list(map(int, stdin.readline().split()))
d.sort(reverse=True)
if d[0] == d[1]:
	(x, y) = (d[0], d[0])
else:
	x = d[0]
	i = 1
	while x % d[i] == 0 and d[i + 1] != d[i]:
		i += 1
	y = d[i]
print(x, y)


n = int(input())
d = list(map(int, input().split()))
d.sort()
num1 = d[n - 1]
b = []
for i in range(1, n):
	if num1 % d[i] != 0:
		b.append(d[i])
	elif d[i - 1] == d[i]:
		b.append(d[i])
num2 = b[len(b) - 1]
print(num1, num2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
X = []
Y = []
for i in a:
	if x % i == 0 and i not in X:
		X.append(i)
	else:
		Y.append(i)
print(x, Y[-1])


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = []
for i in range(n - 1):
	if l[-1] % l[i] != 0:
		a.append(l[i])
if len(a) == 0:
	s = 0
	for i in range(n - 1):
		if l[i] == l[i + 1]:
			s = l[i]
	print(l[-1], s)
else:
	print(l[-1], max(a))


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
f = lst[-1]
for i in range(1, f + 1):
	if f % i == 0:
		lst.remove(i)
print(f, lst[-1])


n = int(input())
l = list(map(int, input().split()))
a = max(l)
print(a, end=' ')
p = [1] * n
f = [1] * 10005
for i in range(n):
	if a % l[i] == 0 and p[i] == 1 and (f[l[i]] == 1):
		p[i] = 0
		f[l[i]] = 0
m = -1
for i in range(n):
	if p[i] == 1 and l[i] > m:
		m = l[i]
print(m)


n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l[-1]
hash = set()
k = []
for i in l:
	if x % i == 0 and i not in hash:
		hash.add(i)
	else:
		k.append(i)
k.sort()
y = k[-1]
print(x, y)


input()
d = {}
for i in map(int, input().split()):
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
a = max(d)
c = 0
for i in d:
	if d[i] == 1 and a % i != 0:
		c = max(c, i)
	elif d[i] == 2 and a % i == 0:
		c = max(c, i)
print(a, c, end=' ')


n = int(input())
d = list(map(int, input().split()))
x = max(d)
nokori = [a for a in d]
kouho = list(set(d))
for v in kouho:
	if x % v == 0:
		nokori.remove(v)
y = max(nokori)
print('{0} {1}'.format(x, y))


n = int(input())
mas = list(map(int, input().split()))
x = max(mas)
mas.remove(x)
new_mas = []
a = set([x])
for r in mas:
	if x % r == 0 and r not in a:
		a.add(r)
	elif x % r == 0 and r in a:
		new_mas.append(r)
	else:
		a.add(r)
		new_mas.append(r)
y = max(new_mas)
print(x, y)


n = int(input())
arr = [int(x) for x in input().split()]
a = max(arr)
arr_a = []
arr_b = []
for i in arr:
	if a % i == 0 and i not in arr_a:
		arr_a += [i]
	else:
		arr_b += [i]
print(a, max(arr_b))


def lcm(a, b):
	aa = a
	bb = b
	while a != b:
		if a > b:
			a = a - b
		else:
			b = b - a
	return aa * bb // a
n = int(input())
a = list(map(int, input().split()))
a.sort()
a1 = a[-1]
a2 = 1
i = 2
while i < len(a) - 1:
	if a[i] == a[i + 1]:
		a2 = lcm(a2, a[i])
		i += 2
	else:
		if a1 % a[i] != 0:
			a2 = lcm(a2, a[i])
		i += 1
print(a1, a2)


n = int(input())
d = [int(t) for t in input().split(' ')]
d.sort()
d.reverse()
d1 = d[0]
d2 = None
for i in range(1, len(d)):
	if d1 % d[i] != 0 or d[i] == d[i - 1]:
		d2 = d[i]
		break
print(d1, d2)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
l.sort()
a = Counter(l)
b = []
skip = -1
for i in range(len(l)):
	if (max(l) % l[i] == 0 and a[l[i]] == 2) and skip != i:
		b.append(l[i])
		l[i] = 0
		skip = i + 1
	elif max(l) % l[i] != 0:
		b.append(l[i])
		l[i] = 0
x = max(l)
y = max(b)
print(x, y)


def main():
	n = int(input())
	d = list(map(int, input().split()))
	d.sort(reverse=True)
	(x, y, s) = (d[0], d[0], set())
	for v in d:
		if x % v != 0:
			y = v
			break
		elif v in s:
			y = v
			break
		else:
			s.add(v)
	print(x, y)
main()


import math
amount = int(input())
array = [int(s) for s in input().split()]
first = max(array)
divisors = []
for i in range(1, int(math.sqrt(first)) + 1):
	if first % i == 0:
		if i * i == first:
			divisors.append(i)
		else:
			divisors.append(i)
			divisors.append(first // i)
used = [0] * len(divisors)
for i in range(len(array)):
	if array[i] in divisors:
		if not used[divisors.index(array[i])]:
			used[divisors.index(array[i])] = 1
			array[i] = 0
print(first, max(array))


n = int(input())
a = [int(s) for s in input().split()]
a.sort()
cnt = [0] * int(10000.0 + 1)
second = -1
for i in range(n):
	if a[-1] % a[i] != 0:
		second = a[i]
	cnt[a[i]] += 1
if second == -1:
	for i in range(int(10000.0 + 1)):
		if cnt[i] == 2:
			second = i
print(a[-1], second)


n = int(input())
x = input()
x1 = list(map(int, x.split(' ')))
ans = max(x1)
for i in range(1, ans + 1):
	if ans % i == 0:
		x1.remove(i)
ans1 = max(x1)
print(ans, end=' ')
print(ans1, end='')


import math
R = lambda : map(int, input().split())
n = int(input())
L = sorted(R())
ma = max(L)
P = [0] * (ma + 1)
for i in L:
	P[i] += 1
for i in range(1, int(math.sqrt(ma)) + 1):
	if ma % i == 0:
		P[i] -= 1
		if i != ma // i:
			P[ma // i] -= 1
for i in reversed(range(ma + 1)):
	if P[i] == 1:
		print(ma, i)
		break


def main():
	int(input())
	a = [0] * 10010
	n = -1000000000.0
	for i in map(int, input().split()):
		a[i] += 1
		n = max(n, i)
	i = 1
	while i * i < n:
		if n % i == 0:
			a[i] -= 1
			a[n // i] -= 1
		i += 1
	if i * i == n:
		a[i] -= 1
	i = 10000
	while a[i] == 0:
		i -= 1
	print(n, i)
main()


size = int(input())
l = list(map(int, input().split()))
ans1 = max(l)
l2 = [item for item in l if ans1 % item != 0]
if len(l2) == 0:
	l3 = []
	for item in l:
		if l.count(item) == 2:
			l3.append(item)
	ans2 = max(l3)
else:
	ans2 = max(l2)
print(f'{ans1} {ans2}')


from functools import reduce
n = int(input())
d = list(map(int, input().split()))
d.sort(reverse=True)
a = d[0]
arr = set()
for i in range(1, a):
	if a % i == 0:
		arr.add(i)
other = []
for j in d[1:]:
	if j in arr:
		arr.remove(j)
	else:
		other.append(j)
other.sort()
print(a, other[-1])


b = []
t = int(input(''))
a = list(map(int, input().split()))
m = max(a)
for i in range(10001):
	b.append(0)
for i in range(t):
	b[a[i]] += 1
a1 = m
for i in range(1, m + 1):
	if m % i == 0:
		b[i] -= 1
for i in range(10000, 0, -1):
	if b[i] == 1:
		a2 = i
		break
print(a1, a2)


from math import gcd
n = int(input())
a = list(map(int, input().rstrip().split()))
p = dict()
if n == 2:
	print(a[0], a[1])
	exit()
for i in a:
	if i in p:
		p[i] += 1
	else:
		p[i] = 1
b = []
c = []
for i in p:
	if p[i] == 2:
		b.append(i)
	if p[i] == 1:
		c.append(i)
a.sort(reverse=True)
for i in range(1, n):
	if gcd(a[i], a[0]) in b:
		my_a = a[0]
		my_b = a[i]
		break
print(my_a, my_b)


n = int(input())
temp = input()
temp = temp.split(' ')
num = []
for x in temp:
	num.append(int(x))
num.sort()
res1 = num[n - 1]
temp = []
for x in range(n - 2, -1, -1):
	if num[x] == num[x + 1] or res1 % num[x] != 0:
		temp.append(num[x])
print(res1, max(temp))


n = int(input())
a = list(map(int, input().split()))
maxx = max(a)
b = []
a.remove(maxx)
for i in range(1, maxx, 1):
	if maxx % i == 0:
		a.remove(i)
	elif i > maxx / 2:
		break
maxx2 = max(a)
print(maxx, maxx2)


b = int(input())
c = list(map(int, input().split()))
c.sort()
d = c[b - 1]
maxi = 1
p = 0
for lop in c:
	if p == 0:
		if c.count(lop) == 2:
			maxi = lop
	if d % lop != 0:
		maxi = lop
		p = 1
print(d, ' ', maxi)


n = int(input())
a = list(map(int, input().split()))
b = [0] * 10001
for i in range(n):
	b[a[i]] += 1
a = sorted(set(a))
a = list(a)
if b[a[len(a) - 1]] == 2:
	start = len(a) - 1
else:
	start = len(a) - 2
for i in range(start, -1, -1):
	c = b.copy()
	for j in a:
		if a[len(a) - 1] % j == 0:
			c[j] -= 1
		if a[i] % j == 0:
			c[j] -= 1
		if c[j] < 0:
			break
	good = True
	for j in c:
		if j != 0:
			good = False
			break
	if good:
		print(a[len(a) - 1], a[i])
		break


def yak(N):
	listmy = []
	for i in range(N):
		nanu = i + 1
		if N % nanu == 0:
			listmy.append(nanu)
	return listmy
a = input()
b = input()
liststr = b.split(' ')
listnum = []
for i in liststr:
	listnum.append(int(i))
maxx = max(listnum)
maxxlist = yak(maxx)
listleft = []
for q in maxxlist:
	listnum.remove(q)
if len(listnum) != 0:
	leftmax = max(listnum)
	print(maxx, leftmax)
else:
	maxxlist.sort()
	print(maxx, maxxlist[1])


n = int(input())
a = list(map(int, input().split()))
l1 = []
l2 = []
ans1 = max(a)
ans2 = 0
a.sort(reverse=True)
for i in range(1, ans1 + 1):
	if ans1 % i == 0:
		a.remove(i)
ans2 = max(a)
print(ans1, ans2)


n = int(input())
d = [int(a) for a in input().split()]
d.sort()
big = d[-1]
for x in range(1, big + 1):
	if big % x == 0:
		d.remove(x)
print(big, d[-1])


x = input()
y = list(map(int, input().strip().split()))
z = max(y)
y.remove(z)
for i in range(1, int(z / 2) + 1):
	if z % i == 0:
		y.remove(i)
a = max(y)
print(z, a)


n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
x = a[-1]
for i in range(n - 2, -1, -1):
	if x % a[i] or x == a[i] or a[i] == a[i - 1]:
		y = a[i]
		break
print(x, y)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[0] == a[1]:
	print(a[0], a[1])
else:
	n1 = a[0]
	a.pop(0)
	while len(a) > 0:
		if a[0] == a[1]:
			print(n1, a[0])
			break
		elif n1 % a[0] == 0:
			a.pop(0)
		else:
			print(n1, a[0])
			break


def get():
	return list(map(int, input().split()))
n = int(input())
a = get()
s = max(a)
a.remove(s)
for i in range(1, s // 2 + 1):
	if s % i == 0:
		a.remove(i)
print(s, max(a))


n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l[n - 1]
y = 0
z = 0
for i in range(n - 2, -1, -1):
	if x % l[i] != 0:
		y = l[i]
		z = 1
		break
c = 0
if z == 0:
	for i in range(n - 1):
		if l[i] == l[i + 1]:
			c = i
	print(x, l[c])
else:
	print(x, y)


n = int(input())
a = map(int, input().split(' '))
a = sorted(a)
existed = set()
a2 = []
x = a[-1]
for d in a:
	if x % d == 0 and d not in existed:
		existed.add(d)
	else:
		a2.append(d)
y = a2[-1]
print(x, y)


from collections import Counter
input()
a = list(map(int, input().split()))
c = Counter(a)
x = max(a)
for i in range(1, int(x ** 0.5) + 1):
	if x % i == 0:
		c[i] -= 1
		if x // i != i:
			c[x // i] -= 1
y = max([x for (x, cc) in c.items() if cc != 0])
print(x, y)


num = input()
divList = [int(x) for x in input().split()]
divList.sort()
a = int(max(divList))
lengthDiv = len(divList)
thing = a + 1
for i in range(len(divList)):
	if divList[lengthDiv - 1 - i] < thing and a % divList[lengthDiv - 1 - i] == 0:
		thing = divList[lengthDiv - 1 - i]
		divList.pop(lengthDiv - 1 - i)
b = int(max(divList))
print(a, end=' ')
print(b)


n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2, -1, -1):
	if l[-1] % l[i] != 0:
		c = l[i]
		break
if c == 0:
	k = l[-1]
	for i in range(n - 2, -1, -1):
		if k == l[i]:
			k = l[i]
			break
		k = l[i]
	print(l[-1], k)
else:
	print(l[-1], c)


_ = input()
a = list(map(int, input().split()))
m = max(a)
s = set()
for i in a:
	if m % i == 0:
		s.add(i)
[a.pop(a.index(i)) for i in s]
print(m, max(a))


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
c = b[-1]
m = []
for i in range(1, c + 1):
	if c % i == 0:
		m.append(i)
		a.remove(i)
print(max(a), end=' ')
print(c)


input()
x = sorted(map(int, input().split()), reverse=True)
a = x[0]
for b in x:
	if x.count(b) > 1 or a % b:
		print(a, b)
		exit(0)


n = int(input())
A = list(map(int, input().split()))
A.sort()
M = max(A)
print(M, end=' ')
k = A.count(M)
for i in range(n):
	k = A.count(A[i])
	if k == 2:
		p = A[i]
		if M % A[i] == 0 and A[i] != 1 and (A[i] != M):
			A[i] = 0
	elif M % A[i] == 0 and A[i] != 1 and (p != A[i]):
		A[i] = 0
m = max(A)
print(m)


n = int(input())
dn = list(map(int, input().split()))
x = max(dn)
x_dic = []
for i in dn:
	if x % i == 0 and i not in x_dic:
		x_dic.append(i)
for i in x_dic:
	dn.pop(dn.index(i))
print(x, max(dn))


import math

def divisors(n):
	d = set()
	s = 0
	i = 1
	while i * i <= n:
		if n % i == 0:
			d.add(i)
			d.add(n // i)
		i += 1
	return d
n = int(input())
div = list(map(int, input().split()))
repeated_div = {n for n in div if div.count(n) == 2}
x_div = set(div)
y_div = repeated_div
while divisors(max(x_div)) != x_div:
	rem = x_div - divisors(max(x_div))
	y_div = y_div | rem
	x_div = x_div - rem
print(max(x_div), max(y_div))


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]

def divisors(n):
	i = 1
	d = []
	while i <= n:
		if n % i == 0:
			d.append(i)
		i += 1
	return d
p = divisors(x)
for ele in p:
	a.remove(ele)
y = a.pop()
print(x, y)


z = int(input())
k = [int(i) for i in input().split()]
k = sorted(k)
k.reverse()
a = []
i = max(k)
for s in range(z):
	if i % k[s] == 0:
		if k[s] not in a:
			a.append(k[s])
			k[s] = 0
print(max(a), max(k))


import math
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = max(a)
s = set()
b = []
for i in a:
	if m % i == 0:
		if i not in s:
			s.add(i)
		else:
			b.append(i)
	else:
		b.append(i)
print(m, max(b))


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
n = I()
A = readInts()
x = max(A)

def yaku(m):
	dic = defaultdict(int)
	i = 1
	while i * i <= m:
		if m % i == 0:
			j = m // i
			dic[i] += 1
			if j != i:
				dic[j] += 1
		i += 1
	return dic
dic = yaku(x)
for i in range(n):
	if dic[A[i]] != 0:
		dic[A[i]] -= 1
		A[i] = -1
y = max(A)
print(x, y)


number = int(input())
a_list = list(map(int, input().split()))
a = max(a_list)
a_list.remove(a)
for i in range(1, a // 2 + 1):
	if a % i == 0:
		a_list.remove(i)
b = max(a_list)
print(a, b)


def solve():
	n = int(input())
	rd = lambda : list(map(int, input().split()))
	arr = rd()
	ma = max(arr)
	vis = [False for i in range(100000)]
	i = 0
	while i < len(arr):
		val = arr[i]
		if ma % val == 0 and (not vis[val]):
			vis[val] = True
			del arr[i]
		else:
			i += 1
	print('{} {}'.format(max(arr), ma))
solve()


def solve():
	int(input())
	a = [*map(int, input().split())]
	b = []
	mx = max(a)
	i = 1
	while i * i <= mx:
		if mx % i == 0:
			b.append(i)
			if mx / i != i:
				b.append(mx / i)
		i += 1
	for x in range(len(b)):
		if b[x] in a:
			a.remove(b[x])
	ans = max(a)
	print(mx, ans)
t = 1
while t:
	solve()
	t -= 1


import sys
n = int(sys.stdin.readline())
d = [int(tmp) for tmp in sys.stdin.readline().split()]
x = max(d)
sdx = set()
ldy = []
for ed in d:
	if x % ed == 0:
		if ed in sdx:
			ldy.append(ed)
		else:
			sdx.add(ed)
	else:
		ldy.append(ed)
y = max(ldy)
print(x, y)


n = int(input())
ll = [int(x) for x in input().split()]
hset = set()
a = max(ll)
b = -1
for i in range(0, n):
	if ll[i] in hset:
		b = max(b, ll[i])
	hset.add(ll[i])
	if a % ll[i] != 0:
		b = max(b, ll[i])
if b == -1:
	b = a
print(a, ' ', b)


def main():
	n = int(input())
	ls = list(map(int, input().split()))
	ls = list(reversed(sorted(ls)))
	m = max(ls)
	for i in range(len(ls) - 1):
		if m % ls[i] == 0 and ls[i] != ls[i + 1]:
			ls[i] = 0
	ls = list(sorted(ls))
	print(m, max(ls))
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
for i in range(n - 1, -1, -1):
	if x % a[i] != 0:
		print(str(a[n - 1]) + ' ' + str(a[i]))
		break
	elif x % a[i] == 0 and a[i] == a[i - 1]:
		print(str(a[n - 1]) + ' ' + str(a[i]))
		break


n = int(input())
d = list(sorted(map(int, input().split()), reverse=True))
a = []
x = max(d)
for i in range(n):
	if x % d[i] == 0:
		if d[i] not in a:
			a.append(d[i])
			d[i] = 0
print(x, max(d))


n = int(input())
l = sorted([int(i) for i in input().split()])
k1 = l[-1]
d = {}
for i in range(n):
	if k1 % l[i] == 0 and l[i] not in d:
		d[l[i]] = 1
		l[i] = 0
for i in range(n - 1, -1, -1):
	if l[i] > 0:
		k2 = l[i]
		break
print(k1, k2)


n = int(input())
num = list(map(int, input().strip().split()))
Max1 = max(num)
for i in range(1, Max1 + 1):
	if int(Max1 % i) == 0:
		del num[num.index(i)]
Max2 = max(num)
print(Max1, Max2)


n = int(input())
d = [int(i) for i in input().split()]
x = max(d)
for i in range(1, x + 1):
	if x % i == 0:
		ind = d.index(i)
		d.pop(ind)
y = max(d)
print(x, y)


import math
T = int(input())
n = list(map(int, input().split()))
x = max(n)
for i in range(1, int(math.sqrt(x)) + 1):
	if i * i == x:
		n.remove(i)
	elif x % i == 0:
		n.remove(x / i)
		n.remove(i)
y = max(n)
print(x, y)


from collections import Counter
import math

def lcm(a, b):
	return a * b // math.gcd(a, b)

def all_lcm(arr):
	ret = arr[0]
	for a in arr:
		ret = lcm(ret, a)
	return ret

def ans(D):
	freqs = Counter(D)
	doubles = []
	for f in freqs:
		if freqs[f] >= 2:
			doubles += [f]
	G = max(doubles)
	L = all_lcm(D)
	B = max(D)
	A = G * L // B
	return (A, B)
input()
D = input().split(' ')
D = list(map(int, D))
print(*ans(D))


n = int(input())
a = [int(s) for s in input().split()]
x = max(a)
a.sort()
k = [-1]
a.pop()
c = y = max(a)
for i in range(len(a)):
	if x % a[i] == 0 and int(a[i] in k) == 0:
		k.append(a[i])
		a[i] = -1
if max(k) == x:
	y = x
else:
	y = max(a)
print(x, y)


n = int(input())
d = list(map(int, input().split()))
d.sort()
x = d[n - 1]
y = d[n - 2]
if x == y:
	print(str(x) + ' ' + str(y))
else:
	i = n - 2
	while x % y == 0:
		if d[i - 1] == d[i]:
			break
		else:
			i -= 1
			y = d[i]
	print(str(x) + ' ' + str(y))


n = int(input())
arr = list(map(int, input().split()))
first = max(arr)
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
arr.sort()
while d[arr[-1]] != 2 and first % arr[-1] == 0:
	arr = arr[:-1]
print(first, arr[-1])


n = int(input())
vis = [0] * 10002
lst = list(map(int, input().strip().split(' ')))
m = max(lst)
x = 0
if lst.count(m) == 2:
	print(m, m)
else:
	c = 0
	for i in range(n):
		if m % lst[i] == 0 and vis[lst[i]] == 0:
			vis[lst[i]] = 1
			c += 1
			lst[i] = 0
	print(m, max(lst))


n_divisors = int(input())
divisors = input().split()
divisors = [int(x) for x in divisors]
divisors.sort()
divisors = list(reversed(divisors))
x = max(divisors)
y = 0
last_value = 0
for value in divisors:
	if last_value == value:
		y = value
		break
	else:
		last_value = value
	if x % value != 0:
		y = value
		break
print(x, y)


n = int(input())
D = list(map(int, input().split()))
x = max(D)
D.remove(x)
Y = []
D.sort()
if x == max(D):
	Y.append(max(D))
else:
	for i in range(len(D)):
		if x % D[i] != 0:
			Y.append(D[i])
	if len(Y) == 0:
		for i in range(len(D) - 1):
			if D[i] == D[i + 1]:
				Y.append(D[i])
print(x, max(Y))


n = int(input())
nums = list(map(int, input().split()))
x = max(nums)
y = 1
for i in nums:
	if x % i or nums.count(i) > 1:
		y = max(y, i)
print(x, y)


import sys
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
input = sys.stdin.readline
t = int(input())
s1 = list(map(int, input().split()))
s1.sort()
num = 1
for i in range(len(s1)):
	num = num * s1[i]
p = s1[len(s1) - 1]
s = factors(p)
s = list(s)
for i in range(len(s)):
	w = s1.index(s[i])
	s1.pop(w)
s1.sort()
q = s1[len(s1) - 1]
print(p, q)


from math import gcd
n = input()
divisors = list(map(int, input().split()))
divisors.sort()
divisors.reverse()
largest_divisor = set()
x = 0
y = 0
for i in divisors:
	if divisors.count(i) == 2:
		largest_divisor.add(i)
x = divisors[0]
del divisors[0]
for i in divisors:
	if gcd(x, i) in largest_divisor:
		print(i, x)
		break


from sys import stdin
input = stdin.buffer.readline
n = int(input())
(*a,) = map(int, input().split())
x = max(a)
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
for i in d:
	if not x % i:
		d[i] -= 1
print(x, end=' ')
x = 0
for i in d:
	if d[i] > 0:
		x = max(x, i)
print(x)


input()
lst = list(map(int, input().split()))
lst.sort()
first = lst[-1]
i = 1
while i <= first:
	if first % i == 0:
		lst.remove(i)
	i += 1
print(first, lst[-1])


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
n = ii()
l = sorted(il())[::-1]
for i in range(1, n):
	if l[0] % l[i] != 0 or l.count(l[i]) > 1:
		print(l[0], l[i])
		break