Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
import bisect
import math

N = int(input())
a = list(map(int, input().split()))
a.sort()
n = a[-1]
harf = n//2
ri = bisect.bisect_left(a, harf)
r = a[ri]
if ri > 0 and abs(harf-r) >= abs(harf-a[ri-1]):
  r = a[ri-1]
print(n, r)
import bisect
import math

N = int(input())
a = list(map(int, input().split()))
a.sort()
n = a[-1]
harf = n/2
ri = bisect.bisect_left(a, harf)
r = a[ri]
if ri > 0 and abs(harf-r) >= abs(harf-a[ri-1]):
  r = a[ri-1]
print(n, r)