Problem:
 Score : 400 points    Problem Statement 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 1 5
6 9 4 2 11      Sample Output 1 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 .       Sample Input 2 2
100 0      Sample Output 2 100 0

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



from operator import itemgetter
def index_sort(A):
    x = []
    for i,a in enumerate(A):
        x.append((a,i))
    return sorted(x, key=itemgetter(0),reverse=True)

n = I()
a = III()

A = index_sort(a)
amax = A[0][0]
index = A[0][1]

temp = float('inf')
for i in range(n):
    if i==index:
        continue
    if abs(amax/2 - a[i])<abs(amax/2 - temp):
        temp = a[i]

print(amax,temp)

Solution (Python):
import heapq

n=int(input())
l=list(map(int,input().split()))
q=[10**9]

for item in l:
    heapq.heappush(q,10**9-item)

lmax=10**9-heapq.heappop(q)

sa=10**10
while True:
    a=10**9-heapq.heappop(q)
    if sa>abs(a+(-lmax//2)):
        sa=abs(a+(-lmax//2))
        ans2=a
        continue
    break

print(lmax,ans2)

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

x = max(a)
b1 = x//2
b2 = (x+1)//2

y = x
z = x
for i in range(len(a)):
    if a[i] != x:
        tmp = min(abs(a[i]-b1), abs(a[i]-b2))
        if tmp < y:
            z = a[i]
        y = min(tmp, y) 

ans = x*z
print(str(x) + ' '+ str(z))

Solution (Python):
N = int(input())
aList = list(map(int,input().split()))
n = max(aList)
rc = n//2
r = min(aList)
for a in aList:
    if a != n and abs(r-rc) > abs(a-rc):
        r = a
print("{} {}".format(n,r))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()

m, r = a[-1], 0
mid = m/2

for i in range(n-1):
    if a[i] >= mid:
        r = a[i] if abs(mid - a[i]) < abs(mid - a[i-1]) else a[i-1]
        break

print(m, r)

Solution (Python):
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<=abs((ans1)/2-b2):ans2=b1
else:ans2=b2

print(ans1,ans2,sep=" ")

Solution (Python):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
i=max(a)
near=max(a)/2
j=a[np.abs(np.asarray(a)-near).argmin()]
if j==i:
    j=min(a)
print(i,j)

Solution (Python):
import math
from bisect import bisect_left

def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

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

A = a.pop(-1)
if A//2 in a:
    print(A, A//2)
elif A % 2 != 0 and A//2 + 1 in a:
    print(A, A//2 + 1)
else:
    x = A//2
    temp = bisect_left(a, x)
    if temp == 0:
        print(A, a[0])
    elif temp == len(a):
        print(A, a[-1])
    else:
        print(A, a[sorted([temp, temp - 1], key = lambda y: abs(x - a[y]))[0]])

Solution (Python):
n = int(input())
a = [int(_) for _ in input().split()]

maximum = max(a)
others = [0] * (n)
for i in range(n):
    if a[i] != maximum:
        others[i] = min(a[i], maximum - a[i])
    else:
        others[i] = -1
choose = others.index(max(others))
ans = [maximum, a[choose]]
print(*ans)

Solution (Python):
import sys
input=sys.stdin.readline

def main():
    _ = int(input())
    A = list(map(int,input().split()))
    A.sort()
    a = A.pop()
    b = 0
    for x in A:
        if abs(a/2-x) < abs(a/2-b):
            b = x
    print(a, b)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input=sys.stdin.readline
import bisect

def main():
    _ = int(input())
    A = list(map(int,input().split()))
    A.sort()
    a = A.pop()
    bi = bisect.bisect_left(A, a//2)
    br = A[bi-1]
    if bi < len(A):
        if abs(a/2-A[bi-1]) > abs(a/2-A[bi]):
            br = A[bi]
    print(a, br)

if __name__ == '__main__':
    main()

Solution (Python):
import math

def comb(a,b):
  return math.factorial(a)//((math.factorial(b)*math.factorial(a-b)))

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

a.sort()
a_max=a[-1]
a=a[:-1]


b = [[abs(i+(-a_max//2)),i] for i in a]
b.sort()
print(a_max, b[0][1])

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

a_i = max(A)
a_j = a_i + 1

A.remove(a_i)
for a in A:
    if abs(a_j - a_i / 2) > abs(a - a_i / 2):
        a_j = a

print(a_i, a_j)

Solution (Python):
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

n = max(A)
r = A[max([(min(a,n-a),i) for i,a in enumerate(A)])[1]]

print(n,r)

Solution (Python):

def main():
    
    N, *A = map(int, open(0).read().split())
    n = max(A)
    mid, r, cur = n / 2, -1, float("inf")
    for i in A:
        if i != n:
            x = abs(mid - i)
            if x < cur:
                r, cur = i, x
    print(n, r)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
x = max(a)
a.remove(x)
ans = float("INF")
for i in range(n-1):
  if abs(ans - x/2) > abs(a[i] - x/2):
    ans = a[i]
print(x, ans)

Solution (Python):
n = int(input())
ls = list(map(int, input().split()))
m = max(ls)
ls.remove(m)
ds = [abs(x - m / 2) for x in ls]
print(m, ls[ds.index(min(ds))])

Solution (Python):
n = int(input())
ls = sorted(map(int, input().split()))
ds = [abs(x - ls[-1] / 2) for x in ls[:-1]]
print(ls[-1], ls[ds.index(min(ds))])

Solution (Python):
n = int(input())
ls = sorted(map(int, input().split()))
res = [ls[-1]]
ds = [(i, abs(x - ls[-1] / 2)) for i, x in enumerate(ls[:-1])]
ds.sort(key=lambda x: x[1])
res.append(ls[ds[0][0]])
print(*res)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX / 2
del A[A.index(MAX)]
B = list(map(lambda a:abs(a-r_A),A))
B.sort()
r1 = int(r_A + B[0])
r2 = int(r_A - B[0])
if r1 in A:
    print(MAX, r1)
else:
    print(MAX, r2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
M = max(a)
a.remove(M)
import numpy as np
print(M,a[np.argmin([abs(i - M/2) for i in a])])

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
max_a = max(a)
ans = [0,10**9]
for i in a[:n-1]:
  if ans[1] > abs(max_a/2 - i):
    ans[0] = i
    ans[1] = abs(max_a/2 - i)
print(max_a,ans[0])

Solution (Python):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
for i in range(N):
    if ans < min(L[i], L[-1] - L[i]):
        ans = L[i]

print(L[i], ans)

Solution (Python):
import bisect


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    a = sorted(a)
    m = a.pop(-1)
    if len(a)==1:
        left,right = 0,0
    else:
        left = bisect.bisect_left(a,m/2)
        right = max(left-1,0)
    
    if abs(m-2*a[left])<=abs(m-2*a[right]):
        print(m,end=" ")
        print(a[left])
    else:
        print(m,end=" ")
        print(a[right])
        
if __name__ == "__main__":
    main()

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

*else_A, max_A = sorted(A)

print(max_A, min(else_A, key=lambda a: abs(max_A/2 - a) ))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    k = max(a)
    tmp = k
    ans = 0
    for i in range(1,N):
        if tmp > abs(k//2-a[i]):
            tmp = abs(k//2-a[i])
            ans = a[i]

    print(k,ans)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
m = max(a)
a.remove(m)
p = m/2
a_m = [abs(a[i]-p) for i in range(n-1)]
print(m, a[a_m.index(min(a_m))])

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
max_a = a[-1]
temp = a[0]
for i in a[1:-1]:
    if abs(i - max_a / 2) < abs(temp - max_a / 2):
        temp = i
print(*[max_a, temp])

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

a.sort()

a_i = a[-1]
tmp = a_i / 2
a_j = a[0]
for j in range(n - 1):
    if abs(tmp - a[j]) < abs(tmp - a_j):
        a_j = a[j]

print(a_i, a_j)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def A():
    a, b, x = LI()
    if a <= x <= a + b:
        print("YES")
    else:
        print("NO")
    return


def B():
    _, m, x = LI()
    a = LI()
    print(min(bisect.bisect_left(a, x), m - bisect.bisect_right(a, x)))
    return


def C():
    n = II()
    x = LI()
    xb = x[::1]
    xb.sort()
    a = xb[n // 2 - 1]
    b = xb[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif x[i] >= b:
            print(a)
        
    return


def D():
    n = II()
    a = LI()
    a.sort()
    maxa = max(a) / 2
    ans = inf
    for i in range(n):
        if abs(maxa - a[i]) < abs(maxa - ans):
            ans = a[i]
    print(max(a), ans)
    return



if __name__ == '__main__':
    D()

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort()


if l[-1]%2 == 0:
  s = l[-1]//2
else:
  s = (l[-1]+1)//2

temp = float('inf')
for i in range(n-1):
  t = abs(l[i]-s)
  if t <= temp:
    p = l[-1]
    q = l[i]
    temp = t
print(p, q)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort()


if l[-1]%2 == 0:
  s = l[-1]//2
else:
  s = (l[-1]+1)//2

temp = float('inf')
for i in range(n-1):
  t = abs(l[i]-s)
  if t <= temp:
    p = l[-1]
    q = l[i]
    temp = t
print(p, q)

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())))

r = A[0]
for i in range(1, n-1):
    if abs(A[i]*2-A[-1]) < abs(r*2-A[-1]):
        r = A[i]
print(A[-1], r)

Solution (Python):
n = int(input())
a = sorted([int(_) for _ in input().split()])[::-1]
m = a[0]
half = m/2
r = a[1]
for i in range(1, n):
    if abs(half-a[i]) < abs(half-r):
        r = a[i]

print(m, r)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)

a1 = A[-1]
dif = float("inf")
for i in range(N-1):
    if abs(A[i] - a1/2) < dif:
        a2 = A[i]
        dif = abs(A[i] - a1/2)

print(*[a1,a2])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
mx=max(a)
d=mx/2
ans=0
for i in a:
  if abs(i-mx/2)<d:
    d=abs(i-mx/2)
    ans=i
print(mx,ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
mx=max(a)
d=mx
ans=0
if n==2:
  print(100,0)
  exit()
for i in a:
  if abs(i-mx/2)<d:
    d=abs(i-mx/2)
    ans=i
print(mx,ans)

Solution (Python):


from bisect import bisect_left

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

mid=mxv//2

r=bisect_left(a,mid) 
if r>=n-1:
    r=0
l=r-1 if r else 0

ans=[mxv]

if abs(mxv/2-a[r])>abs(mxv/2-a[l]):
    ans.append(a[l])
else:
    ans.append(a[r])
print(*ans)

Solution (Python):
n = int(input())
numbers =list(map(int,input().split()))
sornum =sorted(numbers, reverse=True)

ans =0
d_min = sornum[0]

for i in range(n-1):
   d =abs(sornum[0]/2-sornum[i+1])
   if d<d_min:
      d_min =d
      ans = sornum[i+1]

print('{} {}'.format(sornum[0], ans))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

ax = a[-1]
az = 10 ** 9 + 1
for i in range(n-1):
  val = abs(ax/2 - a[i])
  az = min(az, val)
  
  if az == val:
    ay = a[i]
  
print(ax, ay)

Solution (Python):
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[-1]
idx = bisect.bisect_left(a, ai//2)
if abs(ai//2-a[idx]) == abs(ai//2-a[idx-1]):
    if ai % 2 == 0 or idx == len(a)-1:
        print(ai, a[idx-1])
    else:
        print(ai, a[idx])
elif abs(ai//2-a[idx]) > abs(ai//2-a[idx-1]):
    print(ai, a[idx-1])
else:
    print(ai, a[idx])

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

if n == 2:
  print(max(a), min(a))
  exit()

n = max(a)

temp = n / 2
dif = 10 ** 9
r = -1
for i in a:
  if abs(temp - i) < dif:
    dif = abs(temp-i)
    r = i

print(n, r)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
m=max(a)
t=m/2
ta=10**10
c=0
for i in a:
    if i!=m:
        if abs(i-t)<ta:
            ta=abs(i-t)
            c=i
print(m,c)

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    maxA = A[-1]
    v = maxA / 2
    min_d = float('inf')
    min_i = None
    for i in range(n-1):
        d = abs(A[i]-v)
        if min_d > d:
            min_d = d
            min_i = i
    return  maxA, A[min_i]


if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
m=10**10
for i in range(n):
	if abs(a[i]-a[-1]/2)<m:
		m=abs(a[i]-a[-1]/2)
for i in range(n):
	if abs(a[i]-a[-1]/2)==m:
		print(a[-1],a[i])
		break

Solution (Python):
import math
import bisect

N = int(input())

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

a.sort()



l = a[-1]
del a[-1]
a.append(float("inf"))


poi = bisect.bisect_left(a,l / 2)


if poi > 0:

    if abs(l / 2 - a[poi]) > abs(l / 2 - a[poi-1]):
        print (l,a[poi-1])
    else:
        print (l,a[poi])

else:

    print (l,a[poi])

Solution (Python):
import sys

N = int(input())
A = [int(x) for x in input().split()]
A.sort()

ma = max(A)

L = [(abs(A[i] - ma / 2), i) for i in range(N)]
lmin = min(L)

a = ma
b = A[lmin[1]]

print('{} {}'.format(a,b))

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


ans=a.pop(a.index(max(a)))

for i in range(n - 1):
    if a[i] > ans / 2:
        a[i] = [ans - a[i],a[i]]
    else:
        a[i] = [a[i],a[i]]
a = sorted(a,reverse = True)

print(str(ans) + " " + str(a[0][1]))

Solution (Python):
n = int(input())
As = list(map(int, input().split()))
As.sort()
m = As[-1]
k = min(As[:-1], key=lambda A: abs(m/2-A))
print(m, k)

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
def nearest(array,value):
    idx = (np.abs(array-value)).argmin()
    return array[idx]
print(max(a), nearest(a[a<max(a)], max(a)//2))

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
def nearest(array,value):
    idx = (np.abs(array-value)).argmin()
    return array[idx]
print(max(a), nearest(a, max(a)//2) if n>2 else min(a))

Solution (Python):
import bisect

n = int(input())
a_list = sorted(list(map(int, input().split())))

a_i = a_list.pop()

half = a_i / 2

if len(a_list) == 1:
  print(*[a_i, a_list[0]])
  exit()
  
left_index = bisect.bisect_left(a_list, half)

if left_index >= 1:
  if a_list[left_index] - half < half - a_list[left_index-1]:
    print(*[a_i, a_list[left_index]])
  else:
    print(*[a_i, a_list[left_index-1]])
if left_index == 0:
  print(*[a_i, a_list[left_index]])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print(' '.join(map(str, ans)))

Solution (Python):
from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom


n = int(input())
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print(' '.join(map(str, ans)))

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
MAX=a.index(max(a))
half=-1
for i in range(n):
    if abs(a[MAX]//2-a[half])>abs(a[MAX]//2-a[i]) and MAX!=i:
        half=i
print("{} {}".format(a[MAX],a[half]))

Solution (Python):
import bisect

N = int(input())
INF = 10**10
nums = list(map(int, input().split()))
nums.sort()
n_max = nums[-1]
n_half = n_max//2
nums = [-INF] + nums + [INF]
pos = bisect.bisect_left(nums, n_half)
if abs(n_half-abs(n_max-nums[pos])) >= abs(n_half-abs(n_max-nums[pos-1])):
  print(n_max, nums[pos-1])
else:
  print(n_max, nums[pos])

Solution (Python):
import bisect
from bisect import bisect_left, bisect_right

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

ma = max(a)
a.sort()

i = bisect_left(a, ma / 2)

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

Solution (Python):

def main():
    
    N = int(input())
    A = tuple(map(int, input().split()))
    n = max(A)
    mid, r, dif = n / 2, -1, float("inf")
    for i in A:
        if i != n:
            x = abs(mid - i)
            if x < dif:
                r, dif = i, x
    print(n, r)


if __name__ == "__main__":
    main()

Solution (Python):

from bisect import bisect_left as bs


def main():
    
    N = int(input())
    A = sorted(map(int, input().split()))
    if N == 2:
        print(A[1], A[0])
        return
    n, idx = A[-1], bs(A[:-1], A[-1] // 2)
    cand = [(abs(A[i] - n / 2), A[i]) for i in (idx - 1, idx, idx + 1)]
    r = min(cand)[1]
    print(n, r)


if __name__ == "__main__":
    main()

Solution (Python):

from bisect import bisect_left as bs


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    if N == 2:
        print(A[1], A[0])
        return
    n, idx = A[-1], bs(A[:-1], A[-1] // 2)
    r = min(
        (abs(A[idx - 1] - n / 2), A[idx - 1]),
        (abs(A[idx] - n / 2), A[idx]),
        (abs(A[idx + 1] - n / 2), A[idx + 1]),
    )
    print(n, r[1])


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    n = max(A)
    r = A[0] if A[0] != n else A[1]
    cur = r * (n - r)
    for i in A:
        if i != n:
            x = i * (n - i)
            if x > cur:
                r, cur = i, x
    print(n, r)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())

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

ans = 0
d_min = a[-1]
for i in range(n-1):
  d = abs(a[-1]/2 - a[i])
  if d < d_min:
    d_min = d
    ans = a[i]
    
print('{} {}'.format(a[-1], ans))

Solution (Python):
n,a=open(0);*a,=map(int,a.split());m=max(a);print(m,min((abs(m/2-i),i)for i in a)[1])

Solution (Python):
n=int(input())
a=sorted(map(int,input().split()))
ans=a[-1]
m=float('inf')
k=0
for i in range(n):
    if abs(ans/2-a[i])<m:
        m=abs(ans/2-a[i])
        k=i
print(ans,a[k])

Solution (Python):
"""
comb(n,r)
a1, a2, ..., an から2つの数をcomb(ai,aj)が最大になるように選ぶ


2 4 6 9 11
"""

n = int(input())
As  = list(map(int, input().split()))
A_sort = sorted(As)
A_max = max(As)

ans = 100000000000
for a in A_sort[:-1]:
    d1 = abs(A_max / 2 - ans)
    d2 = abs(A_max / 2 - a)
    if d1 >= d2:
        ans = a
print(A_max,ans)

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

l = max(a)
a.remove(l)

minimum = 10 ** 10
p = (l+1) / 2

for v in a:
    if abs(v - p) <= abs(minimum - p):
        minimum = v

print(l,minimum)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a_li = LI()

    a_li.sort()

    n = a_li[-1]
    
    dif = INF
    prev_dif = dif
    for a in a_li[:-1]:
        dif = min(abs(n/2 - a), dif)
        if dif != prev_dif:
            r = a
            prev_dif = dif

    print(n, r)


main()

Solution (Python):

import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n = getint()
values = list(sorted(getints()))

mx = max(values)
idx1 = bisect.bisect_left(values, mx // 2)
idx2 = idx1 - 1 if idx1 > 0 else idx1

if abs(mx - values[idx1] * 2) < abs(mx - values[idx2] * 2):
    idx = idx1
else:
    idx = idx2

print(mx, values[idx])

Solution (Python):
from bisect import bisect_left

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

a = A[-1]
b = float(a) / 2
i = bisect_left(A, b)
if a % 2 == 0 and A[i] == a // 2:
    print(a, a // 2)
else:
    if b - A[i-1] <= A[i] - b:
        print(a, A[i-1])
    else:
        print(a ,A[i])

Solution (Python):
n=int(input())
box=sorted(list(map(int,input().split())))
if len(box)==2:print(max(box),min(box));exit()
max_box=max(box)
target=max_box//2
if max_box%2==0:
    if target not in box:
        box.append(target)
        box=sorted(box)
        add=box.index(target)
        if abs(target-box[add-1])>abs(target-box[add+1]):
            print(max_box,box[add+1])
        else:
            print(max_box,box[add-1])
    else:print(max_box,target)
else:
    if (target+1 not in box) and (target not in box):
        box.append(target)
        box=sorted(box)
        add=box.index(target)
        if abs(target-box[add-1])>abs(target+1-box[add+1]):
            print(max_box,box[add+1])
        else:print(max_box,box[add-1])
    else:
        if target in box:print(max_box,target)
        else:print(max_box,target+1)

Solution (Python):
"""
comb(n,r)
a1, a2, ..., an から2つの数をcomb(ai,aj)が最大になるように選ぶ


2 4 6 9 11
"""

n = int(input())
As  = list(map(int, input().split()))
A_sort = sorted(As)
A_max = max(As)

ans = 100000000000
for a in A_sort[:-1]:
    d1 = abs(A_max / 2 - ans)
    d2 = abs(A_max / 2 - a)
    if d1 >= d2:
        ans = a
print(A_max,ans)

Solution (Python):
from bisect import bisect_left
from bisect import bisect_right

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

ai = a[-1]
a.pop(-1)
aj = 0
middle = ai//2 if ai % 2 == 0 else ai//2+1
if len(a) == 1:
    aj = a[0]
elif a[bisect_left(a, middle)] == middle:
    aj = middle
elif abs(a[bisect_left(a, middle)]-middle) < abs(a[bisect_right(a, middle)-1]-middle):
    aj = a[bisect_left(a, middle)]
else:
    aj = a[bisect_right(a, middle)-1]

print(ai,aj)

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
m=a[n-1]
a=a[:n]
h=m/2
d=abs(a[0]-h)
x=0
for i in range(1,n-1):
  if abs(a[i]-h)<d:
    x=i
    d=abs(a[i]-h)
print(m,a[x])

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

n = max(a)
a.remove(n)
d = list(map(lambda ai: abs(n / 2 - ai), a))
i = d.index(min(d))
r = a[i]

print(n, r)

Solution (Python):
n=int(input())
l=sorted(list(map(int,input().split())))
n1=l[-1]
n2=0
for i in l[:n]:
    tmp=min(i,n1-i)
    if tmp>n2:
        n2=i
print(n1,n2)

Solution (Python):
n = int(input())
a_array = list(map(int, input().split()))

i = 0

for a in a_array:
    i = max(i, a)

j = 0


for a in a_array:
    if a == i:
        continue
    if abs(j - i/2) > abs(a - i/2):
        j = a

print(i, j)

Solution (Python):
import sys
input = sys.stdin.readline

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

    ans1 = max(a)
    half = ans1 / 2
    min_ = abs(a[0] - half)
    ans2 = a[0]
    for i in range(1, N):
        if a[i] != ans1:
            tmp = abs(a[i] - half)
            if tmp <= min_:
                ans2 = a[i]
                min_ = tmp
    print(ans1, ans2)

if __name__ == "__main__":
    main()

Solution (Python):
import bisect

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

a.sort()
a_max = a.pop(-1)
a_half_1 = a[min(bisect.bisect_left(a, a_max // 2), len(a) - 1)]
a_half_2 = a[max(bisect.bisect_left(a, a_max // 2) - 1, 0)]
if abs(a_max / 2 - a_half_1) < abs(a_max / 2 - a_half_2):
    a_half = a_half_1
else:
    a_half = a_half_2

print(a_max, a_half)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
temp = a[-1]
target = a[-1] // 2
for i in range(len(a) - 1):
  if abs(target - a[i]) <= abs(target - temp):
    temp = a[i]
print(a[-1], temp)

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

N = max(a)
a.remove(N)
N2 = N/2

li = [abs(N2 - k) for k in a]
index = li.index(min(li))
m = a[index]

print("{0} {1}".format(N, m))

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

N = max(a)
a.remove(N)
N2 = N/2

li = [abs(N2 - k) for k in a]
index = li.index(min(li))

print("{0} {1}".format(N, a[index]))

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

a.sort()

N = a[-1]
a.pop()

li = [abs(N/2 - k) for k in a]
index = li.index(min(li))

print("{0} {1}".format(N, a[index]))

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

N = max(a)
a.remove(N)

li = [abs(N/2 - k) for k in a]
index = li.index(min(li))

print("{0} {1}".format(N, a[index]))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
import numpy as np 
A.sort()

a1 = A[-1]
ref = a1/2
cmp = np.abs(ref - A[0])
a2 = A[0]
for a in A[1:-1]:
    if cmp > np.abs(ref - a):
        a2 = a
        cmp = np.abs(ref-a)
print(a1,a2)

Solution (Python):
N = int(input())
A_arr = [int(x) for x in input().split()]

A_arr.sort()
Ai = A_arr[-1]
Aj = sorted(A_arr[:-1], key=lambda x:abs(2*x-Ai))[0]

print(Ai, Aj)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
T = max(A)/2
M = max(A)
S = A[0]

for i in range(N-1):
  if M >= abs(A[i] - T):
    M = abs(A[i] - T)
    S = A[i]

print(str(A[N-1])+" "+str(S))

Solution (Python):
n,l=int(input()),list(map(int,input().split()));l.sort();c=l[-1]/2;a=0
for i in l[:-1]:
  if abs(i-c)<abs(a-c):a=i
print(l[-1],a)

Solution (Python):
from bisect import bisect_left

n = int(input())
a = [int(s) for s in input().split()]
a.sort()
ai = a[-1]
j = bisect_left(a, ai // 2)
if j == 0:
    aj = a[j]
elif j == n-1:
    aj = a[j-1]
else:
    aj = a[j] if 2 * a[j] - ai <= ai - 2 * a[j-1] else a[j-1]
print(ai, aj)

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right

import re


from scipy.misc import comb



def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 


n = i_inpl()
a = l_inpl()
max_v = max(a)/2

an = INF
for ai in a:
    if abs(an-max_v) > abs(ai-max_v) and max(a) != ai:
        an = ai
print(max(a), an)

Solution (Python):



import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a.sort()
m = max(a)
l = 0
ans = a[0]
for i in a[:n-1]:
    if l < min(m-i,i):
        l = min(m-i,i)
        ans = i
print(m,ans)

Solution (Python):
i = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]

n = a[0]
m = n // 2
diff = 100200300400500
ans = -1
for i in a[1:]:
    r1 = abs(m - i)
    r2 = abs(m - n + i)
    if min(r1, r2) < diff:
        diff = min(r1, r2)
        ans = i
print(n, ans)

Solution (Python):
from bisect import bisect_left
from sys import stdin



def solve(a):
    a.sort()
    mid = a[n-1]/2
    ai = a[bisect_left(a, mid)-1]
    aj = a[bisect_left(a, mid)]
    am = ai if abs(mid-ai) <= abs(mid-aj) else aj

    print(a[n-1], am)


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, stdin.readline().split()))
    solve(a)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l.sort()
c=l[-1]/2
ans=0
for i in range(n-1):
  if abs(l[i]-c)<abs(ans-c):ans=l[i]
print(l[-1],ans)

Solution (Python):
from operator import mul
from functools import reduce
import bisect

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

A.sort()
mx = A[N-1]
A.pop()

_r = bisect.bisect_right(A, mx/2)
_l = bisect.bisect_left(A, mx/2)
if N == 2:
    
    A = [mx, A[0]]
    print(*A)
    exit()


if _r > N-2:
    _r = N-2
if _l > N-2:
    _l = N-2

if abs(A[_l-1]-(mx/2)) > abs(A[_l]-(mx/2)):
    print(mx, A[_l])
else:
    print(mx, A[_l-1])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
a = max(A)
import math
import bisect
mid = a / 2
left = bisect.bisect_left(A, mid)
min_diff = 1<<50
for diff in [-1, 0]:
    at = left + diff
    diff_abs = abs(A[at]-mid)
    if diff_abs < min_diff:
        min_diff = diff_abs
        b = A[at]

print("%d %d" % (a, b))

Solution (Python):
from bisect import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
b = A.pop()
m = b / 2
i = bisect(A, m)
A.insert(i, m)

if i == 0:
    print(b, A[1])
elif i == len(A) - 1:
    print(b, A[-2])
elif A[i] - A[i - 1] < A[i + 1] - A[i]:
    print(b, A[i - 1])
else:
    print(b, A[i + 1])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans1 = A[-1]
ans2 = -1
for i in range(0, N-1):
	if abs(A[i]-ans1/2) < abs(ans2-ans1/2):
		ans2 = A[i]
print(str(ans1) + ' ' + str(ans2))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
m = max(a)
ans = ' '.join((
    str(m),
    str(max(sorted(a), key=lambda x: min(x, m - x)))
))
print(ans)