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.

-----Constraints-----
 - 2 \leq n \leq 10^5
 - 0 \leq a_i \leq 10^9
 - a_1,a_2,...,a_n are pairwise distinct.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n

-----Output-----
Print a_i and a_j that you selected, with a space in between.

-----Sample Input-----
5
6 9 4 2 11

-----Sample Output-----
11 6

\rm{comb}(a_i,a_j) for each possible selection is as follows:
 - \rm{comb}(4,2)=6 
 - \rm{comb}(6,2)=15 
 - \rm{comb}(6,4)=15 
 - \rm{comb}(9,2)=36 
 - \rm{comb}(9,4)=126 
 - \rm{comb}(9,6)=84 
 - \rm{comb}(11,2)=55 
 - \rm{comb}(11,4)=330 
 - \rm{comb}(11,6)=462 
 - \rm{comb}(11,9)=55
Thus, we should print 11 and 6.

Difficulty: interview

Starter code:

Solutions:
import bisect

_ = input()
a = sorted(map(int, input().split()))

n = a[-1]

m = n / 2
b = bisect.bisect(a, m)
s = a[b - 1]
t = a[b]
if m - s <= t - m:
    print(n, s)
else:
    print(n, t)

n=int(input())
l=sorted(map(int,input().split()))
m=l.pop()
t=h=m/2
r=0
for i in l:
  if (s:=abs(i-h))<t: t,r=s,i
print(m,r)

N=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)
half=a[0]/2
ans1=a[0]
flag=10**9+10

for i in range(1,N):
    if flag>abs(a[i]-half):
        ans2=a[i]
        flag=abs(a[i]-half)

print(ans1,ans2)

n = int(input())
a = list(map(int,input().split()))
a.sort()
j = a[-1]
for i in range(n):
    if a[i]*2 > j:
        break
if j - a[i-1]*2 > a[i]*2 - j:
    print(j,a[i])
else:
    print(j,a[i-1])

from bisect import bisect_right
n=int(input())
a=sorted(list(map(int,input().split())))
x=a[-1]
c=bisect_right(a,x//2)
if x%2==0:
    if x//2 in a:
        print("{} {}".format(x,x//2))
    else:
        if a[c]-x//2>=x//2-a[c-1]:
            print("{} {}".format(x,a[c-1]))
        else:
            print("{} {}".format(x,a[c]))

        
else:
    if x//2 in a :
        print("{} {}".format(x,x//2))
    elif x//2+1 in a:
        print("{} {}".format(x,x//2+1))
    else:
        if a[c]-(x//2+1)>=x//2-a[c-1]:
            print("{} {}".format(x,a[c-1]))
        else:
            print("{} {}".format(x,a[c]))

n = int(input())
a = list(map(int, input().split()))
ma = max(a)
a = a[:a.index(ma)] + a[a.index(ma)+1:]
l = []
for i in range(n-1):
    l.append([abs(ma-2*a[i]), "-" if ma-2*a[i] >= 0 else "+"])
l.sort()
print(ma,end=" ")
print((ma-l[0][0])//2) if l[0][1] == "-" else print((ma+l[0][0])//2)

import bisect
n,*A=map(int,open(0).read().split());A.sort();m=A[-1];i=bisect.bisect_right(A,m/2)
print(m,[A[i-1],A[i]][abs(A[i-1]-m/2)>abs(A[i]-m/2)])

import bisect
n=input()
a=sorted(map(int,input().split()))
m=a[-1]
q=bisect.bisect_right(a,m/2)
p=q-1
if abs(m/2-a[p])>abs(m/2-a[q]):print(m,a[q])
else:print(m,a[p])

n = int(input())
a = list(map(int,input().split()))
ai = max(a)
a.remove(ai)
aj = a[0]
for i in a:
    if abs(ai/2-i) < abs(ai/2-aj):
        aj = i
print(ai,aj)

n = int(input())
aa = sorted(list(map(int, input().split())))
list1 = []
ma = aa[-1]
for i in range(n):
  d = abs(aa[i]-(ma+1)//2)
  list1.append([d,i])
md = min(list1, key=lambda x:x[0])

print(ma, aa[md[1]])

import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
m = A[-1]
i = bisect.bisect_left(A, m/2)
if i == 0:
  print(m, A[0])
  return
if i == N-1:
  print(m, A[-2])
  return
a, b = A[i-1], A[i]
if abs(a*2-m) > abs(b*2-m):
  print(m, b)
else:
  print(m, a)

from bisect import bisect_left
N = int(input())
a = list(map(int,input().split()))
a.sort()
x = a[-1]
i = bisect_left(a, x/2, hi=N-2)
for j in [i-1, i, i+1]:
    if 0 <= j < N and abs(a[j]-x/2) < abs(a[i]-x/2):
        i = j
print(x, a[i])

n = int(input())
aa = list(sorted(map(int, input().split())))
x = max(aa)
y = aa[0]
for i in range(1, n - 1):
    if abs(x / 2 - y) > abs(x / 2 - aa[i]):
        y = aa[i]
print(("{} {}".format(x, y)))


n = int(input())
list_A = list(map(int, input().split()))
m = max(list_A)
r, k = 0, 0
for a in list_A:
    if min(m-a, a) > k:
        r = a
        k = min(m-a, a)
 
print(m, r)

import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
num=a[-1]/2
b=bisect.bisect_left(a,num)
if abs(num-a[b])<abs(num-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

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

a.sort()

ans_n = a[-1]
del a[-1]
ans_r = a[0]

dif = 1001001000
for i in range(n-1):
    if dif > abs(ans_n / 2 - a[i]):
        ans_r = a[i]
        dif = abs(ans_n / 2 - a[i])

print('%d %d' % (ans_n, ans_r))

n=int(input())
l=sorted(map(int,input().split()))
m=l.pop()
h=m/2
t,r=h,0
for i in l:
  if (s:=abs(i-h))<t: t,r=s,i
print(m,r)

n = int(input())
a = list(map(int, input().split()))
a.sort()
l = a[-1]
def bigger(ind):
    nonlocal a, n, l
    if a[ind] > l / 2:
        return True
    else:
        return False
top = n
bottom = -1
while top - bottom > 1:
    mid = (top + bottom) // 2
    if bigger(mid):
        top = mid
    else:
        bottom = mid
if a[top] + a[bottom]> l or a[top] == l:
    print(l, a[bottom])
else:
    print(l, a[top])

def main():
    _ = int(input())
    a = [int(an) for an in input().split()]
    a.sort()
    half_val = -(-a[-1] // 2)
    dist_list = [abs(half_val - an) for an in a[:-1]]
    min_index = dist_list.index(min(dist_list))
    print(f'{a[-1]} {a[min_index]}')


def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3


def solve(n,a):
  a = list(sorted(a,reverse=True))
  first = a[0]
  b = a[1:]
  delta = [abs(x-first//2) for x in b]
  second = b[delta.index(min(delta))]
  return first,second

def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(*solve(N,a))

def __starting_point():
  main()
__starting_point()

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def get_primenumber(number):#素数列挙
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list
def factrization_prime(number):#素因数分解
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
a = l()

a.sort()
a = a[::-1]
A = a[0]
del a[0]
b = inf
c = 0

for i in a:
    if b > abs(A//2-i):
        b = min(b,abs(A//2-i))
        c = i

print(f"{A} {c}")

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

num = a[0]
tmp = a[1]
for j in range(1, n):
  if abs(tmp-num/2) >= abs(a[j]-num/2):
    tmp = a[j]
  else:
    break
ans = [num, tmp]
print(*ans)

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

a.sort()

maxa=max(a)
ans=0
ch=0

for i in range(n-1):
  b=maxa-a[i]
  c=min(b,a[i])
  if c>=ch:
    ans=a[i]
    ch=c
    
print(str(maxa)+' '+str(ans))

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 sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

n = max(A)
mid = n / 2
r = float("inf")
for a in A:
    if a == n:
        continue
    if abs(mid - r) > abs(mid - a):
        r = a

print(n, r)

n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
mid = m / 2

d = 10 ** 9
for ai in a[:-1]:
    x = abs(mid - ai)
    if x < d:
        ans = ai
        d = x

print(m, ans)

n = int(input())
a = list(map(int,input().split()))
a.sort()
l = a[-1]
x = l // 2
y = 10 ** 12
z = 0
for i in range(n-1):
    if y >= abs(x-a[i]):
        y = abs(x-a[i])
        z = i
print(l,a[z])

def solve():
  N = int(input())
  A = [-float('inf')]+list(map(int, input().split()))
  A.sort()
  ans = [A[-1]]
  n = A[-1]//2
  for i in range(1,N+1):
    if A[i]>n or i==N-1:
      if A[i]-n>n-A[i-1]:
        ans.append(A[i-1])
      else:
        ans.append(A[i])
      break
  return ans
print(*solve())

N = int(input())
A = list(map(int, input().split()))

A.sort()
x = A[-1]
A.pop()

z = x*10

for a in A:
    if abs(x-a*2) < abs(x-z*2):
        z = a

print(x, z)

from bisect import bisect_left, bisect_right
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
n = a[-1]
mid = a[-1] // 2
i = bisect_left(a[:-1], mid)

if i >= len(a) - 1:
    r = a[i - 1]
elif i == 0 or a[i] == mid:
    r = a[i]
elif a[i] - mid <= mid - a[i - 1]:
    r = a[i]
else:
    r = a[i - 1]

print(n, r)

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

max_a = max(a)

ans = 0
for i in range(n):
    if abs(ans - max_a/2) > abs(a[i] - max_a/2):
        ans = a[i]

print(max_a, ans)

n=int(input())-1
a=sorted(list(map(int,input().split())))
k=a[-1]
kk=k//2
x,b=10**9,10**9
for i in range(n):
    if abs(a[i]-kk)<=x:
        x=abs(a[i]-kk)
        b=a[i]
print(k,b)

import bisect
n = int(input())
A = list(map(int,input().split()))
A.sort()
if n == 2:
  ans = [A[1],A[0]]
  print(*ans)
  return
MAX = A[-1]
target = MAX//2
ok = 0
ng = n
while abs(ok-ng)>1:
  mid = (ok+ng)//2
  if A[mid] <= target:
    ok = mid
  else:
    ng = mid
ans = [MAX,A[ok]]

nxt = ok+1
#print(A[nxt])
if nxt < n:
  dif0 = min(MAX-A[ok],A[ok])
  dif1 = min(MAX-A[nxt],A[nxt])
  if dif0 < dif1:
    ans[1] = A[nxt]
print(*ans)

N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A[-1]

d = n
r = -1
for a in A[:-1]:
    if n%2==0:
        t = abs(a - n//2)
        if t < d:
            d = t
            r = a
    else:
        t = min(abs(a - n//2), abs(a - (n//2+1)))
        if t < d:
            d = t
            r = a
print(n,r)

def getval():
    n = int(input())
    a = list(map(int,input().split()))
    return n,a

def main(n,a):
    a.sort()
    c = a[n-1]
    R = c/2
    r = 0
    for i in a:
        if abs(R-i)<abs(R-r):
            r = i 
    print("{x} {y}".format(x=c,y=r))

def __starting_point():
    n,a = getval()
    main(n,a)
__starting_point()

N=int(input())
A=list(map(int,input().split()))

if N == 2:
  print(*(max(A),min(A)))
  return
  
m = max(A)/2
nearest=-1
for i in range(N):
  if abs(A[i]-m)<abs(nearest-m):
    nearest = A[i]

print(*(max(A),nearest))

N = int(input())
a = list(map(int,input().split()))
ma = max(a)
a.remove(ma)
num = 0
ind = 0
a.sort()
for i in range(N-1):
    if a[i] < ma//2:
        ind += 1

if ind == 0:
    print(ma,a[0])
    return
elif ind == N-1:
    print(ma,a[-1])
    return

if abs(ma//2 - a[ind-1]) < abs(ma//2 - a[ind]):
    print(ma,a[ind-1])
else:
    print(ma,a[ind])

n = int(input())
list_A = list(map(int, input().split()))
m = max(list_A)
r, k = 0, 0
for a in list_A:
    if min(m-a, a) > k:
        r = a
        k = min(m-a, a)

print(m, r)

n = int(input())
L = list(map(int,input().split()))
L .sort()

maxL = L[-1]
li = [abs(x-maxL/2) for x in L]

a = li.index(min(li))
print(maxL,L[a])

import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    n = I()
    a = LI()

    mx = max(a)
    a.remove(mx)

    r = (float("inf"), -1)
    half = mx//2
    
    if mx%2 == 0:
        for x in a:
            sa = abs(x-half)
            if sa < r[0]:
                r = (sa, x)
    else:
        for x in a:
            sa = min(abs(x-half), abs(x-(half+1)))
            if sa < r[0]:
                r = (sa, x)

    ans = (mx, r[1])
    print((*ans))
            

                    


main()


_=int(input())
a=list(map(int,input().split()))
a.sort()
n=max(a)
a=a[:-1]

rc=float('inf')
rd=0
r=0
for i in a:
  if rc>abs(i-n/2):
    r=i
  rc=min(rc,abs(i-n/2))
  
print(n,r)

N = int(input())
A = sorted(list(map(int,input().split())))
B = A[-1]
print(B,min(A,key=lambda x: abs(B-2*x)))

import bisect

def main():
    n=int(input())
    a=sorted(map(int,input().split()))
    if len(a) < 3:
        print(a[1], a[0])
        return
    N = a[-1]
    a = a[:-1]
    r = bisect.bisect(a, N/2)
    if r == 0:
        R = a[0]
    if r == len(a):
        R = a[r-1]
    else:
        R = a[r] if abs(a[r-1] - N/2) > abs(a[r] - N/2) else a[r-1]
    print(N, R)
        
def __starting_point():
    main()
__starting_point()

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
r = a.pop(0)
s = r
temp = 0
for i in range(n-1):
    if abs(r - 2*a[i]) < s:
        s = abs(r - 2*a[i])
        temp = a[i]
print(r, temp)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = a[1]
for i in range(1, n-1):
  if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]):
    ans = a[i+1]
  else:
    break
print(a[0], ans)

n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
cand=a[1]
for i in range(1,n-1):
  if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]):
    cand = a[i+1]
  else:
    break
print(a[0], cand)

n = int(input())
a = sorted(map(int, input().split()))
p = a[-1]
c = 0
for i in range(n-1):
  if abs(a[i+1]-p/2) < abs(a[i]-p/2):
    c = a[i+1]
  else:
    break
print(p,c)

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
m = max(a) // 2
res = 0
c = max(a)
for i in range(n-1):
  if abs(m - a[i]) <= c:
    res = a[i]
    c = abs(m - a[i])
print(max(a),res)

import bisect

_ = int(input())
a = sorted(map(int, input().split()))

n = a[-1]

m = n / 2
b = bisect.bisect(a, m)
s = a[b - 1]
t = a[b]
if m - s <= t - m:
    print(n, s)
else:
    print(n, t)

import itertools
n = int(input())
a = list(map(int, input().split()))
m = max(a)
t = (10**9)+1
for i in a:
    if abs(i-(m//2)) < t and i != m:
        t = abs(i-(m//2))
        s = i
print(m,s)

from bisect import bisect_left, bisect_right

n = int(input())
al = list(map(int, input().split()))
al.sort()
ai = al[-1]
if ai%2 == 0:
    aj_best = ai//2
    ind = bisect_right(al, aj_best) - 1
    ind = ind if 0 <= ind < n else None
    val1 = al[ind] if ind is not None else 0

    ind = bisect_left(al, aj_best)
    ind = ind if 0 <= ind < n else None
    val2 = al[ind] if ind is not None else ai

    if abs(aj_best-val1) <= abs(aj_best-val2):
        aj = val1
    else:
        aj = val2


else:
    aj_best = ai//2
    ind = bisect_right(al, aj_best) - 1
    ind = ind if 0 <= ind < n else None
    val1 = al[ind] if ind is not None else 0

    ind = bisect_left(al, aj_best)
    ind = ind if 0 <= ind < n else None
    val2 = al[ind] if ind is not None else ai

    if abs(aj_best-val1) <= abs(aj_best+1-val2):
        aj = val1
    else:
        aj = val2

print(ai,aj)

import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()

t, r = divmod(A[-1], 2)
idx = bisect.bisect_left(A, t)

if r == 1:
    if idx != 0:
        if abs(A[idx - 1] - t) < abs(A[idx] - t):
            idx = idx - 1
else:
    if idx != 0:
        if abs(A[idx - 1] - t) <= abs(A[idx] - t):
            idx = idx - 1

print((' '.join([str(A[-1]), str(A[idx])])))



n=int(input())
a=list(map(int,input().split()))
a.sort()
b=a[-1]/2
tmp=a[-1]
for i in range(n):
  if tmp>abs(b-a[i]):
    ans=a[i]
    tmp=abs(b-a[i])
print(a[-1],ans)

n = int(input())
a = list(map(int,input().split()))
ma = max(a)
cnt = 10**9
mid = ma/2
for i in range(n):
    if abs(cnt - mid) >= abs(mid - a[i]):
        cnt = a[i]
print(max(ma,cnt),min(ma,cnt))

n=int(input())
a=list(map(int,input().split()))
a.sort()
s=a[-1]/2
b=[[i,abs(i-s)] for i in a]
b.sort(key=lambda z:z[1])
print(a[-1],b[0][0])

N = int(input())
lsa = list(map(int,input().split()))
n = max(lsa)
r = 0
for i in range(N):
    r1 = lsa[i]
    if min(r1,n-r1) >= min(r,n-r):
        r = r1
print(n,r)

N = int(input())
A = list(map(int, input().split()))
A.sort()
A.append(10**12)
MAX = A[N-1]
ans = N
for i in range(N):
    if abs(A[i] - MAX/2) < abs(A[ans] - MAX/2):
        ans = i
print(MAX,A[ans])

import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
x = a[-1]
N = a[-1]//2

a = a[:-1]
y = bisect.bisect_left(a,N)
if len(a) <= y: ans = a[y-1]
else:
    ans = a[y]
    if 0 < y and abs(N-ans) > abs(N-a[y-1]): ans = a[y-1]
    if y < len(a)-1 and abs(N-ans) > abs(N-a[y+1]): ans = a[y+1]
print(x,ans)

N = int(input())
A = list(map(int,input().split()))

A_max = max(A)

A.remove(A_max)

X = [abs(a-(A_max//2)) for a in A]

X_min_id = X.index(min(X))

print(A_max,A[X_min_id])

import bisect

_ = input()
a = [int(i) for i in input().split()]

a.sort()
n = a[-1]

m = n / 2
b = bisect.bisect(a, m)
s = a[b - 1]
t = a[b]
if m - s <= t - m:
    print(n, s)
else:
    print(n, t)

def main():
	n = int(input())
	A = [int(a) for a in input().split(" ")]
	A.sort(reverse=True)
	ans = []
	f = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
	if A[0] <= 10:
		for i in range(n):
			for j in range(i + 1, n):
				ans.append({
					"max" : A[i],
					"min" : A[j],
					"comb" : int(f[A[i]] / (f[A[j]] * f[A[i] - A[j]]))
				})
		ans.sort(key=lambda s : -s["comb"])
		print(ans[0]["max"], ans[0]["min"])
		return 0

	i = 0
	j = 1
	while i < n and j < n:
		M = A[i]
		m = A[j]
		if abs(A[i] / 2 - A[j]) <= 0.5:
			ans.append({"max": A[i], "min": A[j], "dif": abs(A[i] / 2 - A[j]), "k": min([A[j], A[i] - A[j]])})
			i += 1
		elif A[i] / 2 < A[j]:
			if j < n - 1:
				j += 1
			else:
				ans.append({"max": A[i], "min": A[j], "dif": abs(A[i] / 2 - A[j]), "k": min([A[j], A[i] - A[j]])})
				j += 1
		elif A[i] / 2 > A[j]:
			if abs(A[i] / 2 - A[j - 1]) > abs(A[i] / 2 - A[j]) or j == i + 1:
				ans.append({"max": A[i], "min": A[j], "dif": abs(A[i] / 2 - A[j]), "k": min([A[j], A[i] - A[j]])})
			else:
				ans.append({"max": A[i], "min": A[j - 1], "dif": abs(A[i] / 2 - A[j - 1]), "k": min([A[j - 1], A[i] - A[j - 1]])})
			i += 1
		if i == j:
			j += 1

	ans.sort(key=lambda s: (-s["k"], -s["max"]))
	k_cand1 = ans[0]["k"]
	ans2_idx = 0

	for i in range(len(ans)):
		if ans[i]["k"] == k_cand1 - 1:
			ans2_idx = i
	if ans2_idx and ans[0]["max"] < ans[i]["max"]:
		print(ans[i]["max"], ans[i]["min"])
	else:
		print(ans[0]["max"], ans[0]["min"])



main()

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

nmax = max(a)
target = nmax/2

cur = a[0] if a[0] != nmax else a[1]
curdiff = abs(cur-target)

for i in range(n):
    if a[i] == nmax:
        continue

    diff = abs(a[i]-target)

    if diff < curdiff:
        curdiff = diff
        cur = a[i]

print(nmax, cur)

N = int(input())
A = list(map(int,input().split()))

A.sort()
max_el = A[-1]
median = max_el//2
import bisect
median_ind = bisect.bisect_left(A,median)

if median_ind == 0:
    print(A[-1],A[0])
    return
if median_ind == N-1:
    print(A[-1],A[-2])
    return

abs_right = abs(A[median_ind]-median)
abs_left = abs(A[median_ind-1]-median)

if abs_right>abs_left:
    print(A[-1],A[median_ind-1])
    return

print(A[-1], A[median_ind])