CF BUDDY
← Problems·

1108B · Divisors of Two Integers

1100 · brute force, greedy, math

Problem: Recently you have received two positive integer numbers xx and yy. You forgot them, but you remembered a shuffled list containing all divisors of xx (including 11 and xx) and all divisors of yy (including 11 and yy). If dd is a divisor of both numbers xx and yy at the same time, there are two occurrences of dd in the list.

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

Your problem is to restore suitable positive integer numbers xx and yy 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 xx and yy.

Input Format: The first line contains one integer nn (2n1282 \le n \le 128) — the number of divisors of xx and yy.

The second line of the input contains nn integers d1,d2,,dnd_1, d_2, \dots, d_n (1di1041 \le d_i \le 10^4), where did_i is either divisor of xx or divisor of yy. If a number is divisor of both numbers xx and yy then there are two copies of this number in the list.

Output Format: Print two positive integer numbers xx and yy — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.

Sample Cases

Case 1

Input

10
10 2 8 1 2 4 1 20 4 5

Output

20 8

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback