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):
n = int(input())
a = [int(s) for s in input().split()]

combn = max(a)

ar = [abs(num-combn/2) for num in a]
if int(combn/2 - min(ar)) in a:
  combr = int(combn/2 - min(ar))
else:
  combr = int(combn/2 + min(ar))

print(' '.join(map(str,[combn,combr])))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
M = max(a)
m = M/2
tmp = 1e9
for i in range(n-1):
    if tmp > abs(a[i]-m):
        tmp = abs(a[i]-m)
        ans = i

print(M,a[ans])

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

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
ai = max(arr)
aj = 0
min_aj = float('inf')
for i in arr:
    if i == ai:
        continue
    if abs((ai - i) - i) < min_aj:
        min_aj = abs((ai - i) - i)
        aj = i
print(ai,aj)

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

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M < m:
        aj = A[i]
        M = m

print(ai,aj)

Solution (Python):
n=int(input())
 
t = list(map(int,input().split()))
t.sort()
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans > abs(a1/2-i):
        ans = abs(a1/2-i)
        memo = i
print(a1, memo)

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

left = a[-1]
sa = 199999999999999999999999999
for i in range(n):
  if sa > abs((left/2) -a[i]):
    right = a[i]
    sa = abs((left/2) - a[i])
    
print(left, right)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort()
n=a[-1]
r=0

tmp=0
for i in range(N):
    b=min(a[i],n-a[i])
    if tmp<b:
        tmp=b
        r=a[i]

print(str(n)+" "+str(r))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
l = a[0]
del a[0]
r = min(a,key = lambda x:abs((l/2)-x))
print(l,r)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

n = max(A)
mid = n / 2

dic = defaultdict(int)
for i in range(N):
    dic[A[i]] = abs(A[i] - mid)
    
dic = sorted(dic.items(), key=lambda x:x[1])
k = dic[0][0]



print(n, k)

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

a.sort()

ans = (0,0)
import bisect
i = n-2
j = bisect.bisect_left(a, a[n-1]//2)
if j < n-1: i = j
if j > 0:
    if (a[n-1] - 2*a[j-1]) < (2*a[j] - a[n-1]): i = j-1

print('{} {}'.format(a[n-1], a[i]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a.pop(-1)
b = [min(i, abs(max_a-i)) for i in a]
print(max_a, a[b.index(max(b))])

Solution (Python):
class cmbs(object):
    def __init__(self, mod):
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 10 ** 6 + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)
    def cmb(self, n, r):
        if n > 10 ** 6:
            return self.cmbl(n, r)
        return self.cmbr(n, r)
    def cmbr(self, n, r):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod
    def cmbl(self, n, r):
        t = 1
        r = min(r, n-r)
        for i in range(n - r + 1, n + 1):
            t = t * i % self.mod
        return t * self.g2[r] % self.mod
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    x = a[-1]
    a = a[:-1]
    l = [abs(i - x/2) for i in a]
    print(x)
    print(a[l.index(min(l))])
main()

Solution (Python):
import bisect

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

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

if n%2==0:
    middleIdx=bisect.bisect_left(a[:N-1],n//2)
    
    if a[middleIdx]==n//2:
        r=a[middleIdx]
    elif a[min(middleIdx,N-2)]-n//2 > n//2-a[max(middleIdx-1,0)]:
        r=a[max(middleIdx-1,0)]
    else:
        r=a[min(middleIdx,N-2)]
    print(n,r)
else:
    m1=bisect.bisect_left(a[:N-1],n//2)
    m2=bisect.bisect_left(a[:N-1],n//2+1)
    if a[m1]==n//2:
        r=a[m1]
    elif a[m2]==n//2+1:
        r=a[m2]
    elif a[min(m2,N-2)]-(n//2+1) > n//2-a[max(m1-1,0)]:
        r=a[max(m1-1,0)]
    else:
        r=a[min(m2,N-2)]
    print(n,r)

Solution (Python):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
ai = a.max()

v, aj = 0, 0
for i in a:
    tmp = i * (ai - i)
    if v < tmp:
        v = tmp
        aj = i

print(*(ai, aj))

Solution (Python):
import numpy as np

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

ai = a.max()

v, aj = 0, 0
for i in a[:-1]:
    tmp = i * (ai - i)
    if v < tmp:
        v = tmp
        aj = i

print(ai)
print(aj)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans1 = max(a)
a.remove(ans1)
val = ans1 / 2
ans2 = int(1e10)
val2 = int(1e10)

for i in range(n-1):
    if abs(a[i] - val) < val2:
        ans2 = a[i]
        val2 = abs(a[i] - val)
        
print(ans1, ans2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = max(a)
half = x/2
y = sorted([ai for ai in a if ai < x], key=lambda x: abs(half-x))[0]
print("{} {}".format(x,y))

Solution (Python):
from bisect import bisect


n = int(input())
A = sorted(map(int, input().split()))


x = A[-1]

A = [-float("inf")] + A[:n - 1] + [float("inf")]
i = bisect(A, x / 2)
if abs(A[i - 1] - x / 2) < abs(A[i] - x / 2):
    y = A[i - 1]
else:
    y = A[i]


print(x, y)

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

a.sort()

ans = 0
tmp = 10 ** 9

for i in a:
    if tmp > abs(i - a[n - 1] / 2):
        tmp = abs(i - a[n - 1] / 2)
        ans = i

print(a[n - 1], ans)

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

left = max(A)

right = 0
dif_min = 10**10
mid = (max(A)/2)

for i in range(n):
    if A[i] == left:
        continue
    dif = abs(A[i] - mid)
    if dif <= dif_min:
        dif_min = dif
        right = A[i]

print(str(left) + ' ' + str(right))

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

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

ans = [-1, 0, 0]

import bisect

i = a[-1]
idx = [bisect.bisect_left(a, i / 2), bisect.bisect_left(a, i / 2) - 1]

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

Solution (Python):
from bisect import bisect

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

x=a[-1]

if n%2==0:
  mid=x//2
else:
  mid=x//2+1

if mid in a:
  print(x,mid)
else:
  inx=bisect(a,mid)
  if a[inx]-mid>=mid-a[inx-1]:
    print(x,a[inx-1])
  else:
    print(x,a[inx])

Solution (Python):
from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
ans_bigger = max(a)
ans_half = ans_bigger / 2
dif = float("inf")
for i in range(n-1):
  x = abs(a[i]-ans_half)
  if dif > x:
    dif = x
    ans_smaller = a[i]
print(ans_bigger,ans_smaller)

Solution (Python):
def main():
    from bisect import bisect_right
    n=int(input())
    num=list(map(int,input().split()))
    num.sort()
    
    i=bisect_right(num,num[-1]//2)
    if i==0:
        ans=num[0]
    else:
        if num[-1]>num[i]+num[i-1]:
            ans=num[i]
        else:
            ans=num[i-1]
    print(num[-1],ans)

if __name__=='__main__':
    main()

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
X=A[-1]
m=X
p=A[0]
for a in A[:-1]:
  if abs(a-X/2)<m:
    m=abs(a-X/2)
    p=a
  else:
    break
print(X,p)

Solution (Python):
import bisect
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
m=b[-1]
tmp=m/2

t=bisect.bisect_left(b,tmp)
ans=0
if(b[t]==tmp):
    ans=b[t]
elif(t==0):
    ans=b[0]
elif(t==len(b)-1):
    ans=b[-2]
else:
    c=abs(tmp-b[t-1])
    d=abs(tmp-b[t])
    if(c<=d):
        ans=b[t-1]
    else:
        ans=b[t]
print(m,ans)

Solution (Python):
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

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

Solution (Python):
import bisect

N = int(input())
a = list(map(int,input().split()))
a.sort()
a_max = a.pop()
idx = bisect.bisect_left(a,a_max/2)
if 1 <= idx and idx != N-1:
    if a_max/2-a[idx-1] < a[idx]-a_max/2:
        idx -= 1
print(a_max,a[idx] if idx < N-1 else a[N-2])

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

a.sort()
an = a[-1]
a.pop()

rx = an/2
mx = rx - a[0]
r = a[0]
for i in a:
    if mx > abs(rx - i):
        mx = abs(rx - i)
        r = i

print(an, r)

Solution (Python):
import math
import numpy

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def get_nearest(li, num):
    index = numpy.abs(numpy.asarray(li) - num).argmin()
    return li[index]

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

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

ans_a = max(a)
ans_b = get_nearest(a, ans_a/2)

print(ans_a, ans_b)

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

MAX=max(a)
Harf=MAX/2

cnt=10**20
ans=0
for i in range(n):
    if MAX==a[i]:
        continue
    elif abs(Harf-a[i])<cnt:
        ans=a[i]
        cnt=abs(Harf-a[i])
print(MAX,ans)

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

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

num2=-1
for i in a:
    if abs(num1/2 - i)  < abs(num1/2 - num2):
        num2=i
print(num1,num2)

Solution (Python):
from math import ceil
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
A.remove(ans_1)
ans_2 = 1000000
d = 10000000000
half = ceil(ans_1/2)
for e in A:
    if d > abs(half-e):
        d = abs(half-e)
        ans_2 = e
print(ans_1,ans_2)

Solution (Python):
import bisect

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

numbers.sort()
maximum = numbers[-1]

half = maximum/2
index = bisect.bisect_left(numbers, half)
if index != 0:
    if numbers[index] - half < half - numbers[index-1]:
        print('{} {}'.format(maximum, numbers[index]))
    else:
        print('{} {}'.format(maximum, numbers[index-1]))
else:
        print('{} {}'.format(maximum, numbers[0]))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = a[:]
bs = set(b)
f = a[-1]
for i in range(n):
    a[i] = min(a[i],f-a[i])
a.sort()
s = a[-1]
if s in bs:
    print(f,s)
    exit()
s = f - s
print(f,s)

Solution (Python):
import numpy as np
N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
    print(M, *A)
    quit()
print(M, A[np.abs(np.array(A, dtype=np.int64) - M / 2).argmin()])

Solution (Python):
import numpy as np

N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
    print(M, *A)
    quit()

argmin = np.abs(np.array(A, dtype=np.int64) - M / 2).argmin()
print(M, A[argmin])

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
ans = a[-1]
x = ans//2
m = x-a[0]
ans2 = a[0]
for i in a[1:]:
    if i!=ans:
        z = min(i,ans-i)
        dif = x-z
        if m>dif:
            m,ans2 = dif,i
print(ans,ans2)

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))
MAX = a[-1]
mid = MAX // 2
b = float('inf')
for i in a:
    
    if abs(mid - i) <= b and i != MAX:
        b = mid - i
        y = i

print(MAX, y)

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


ans=[a[-1],a[0]]

target=a[-1]/2
d=10**9
for i in range(N-1):
    diff=abs(a[i]-target)
    if diff<d:
        d=diff
        ans[1]=a[i]

            
print(' '.join(map(str, ans)))

Solution (Python):


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

M=max(A)
l=0
for i in range(n):
    if abs(M/2-A[i])<abs(M/2-l):
        l=A[i]
        
print(M,l)

Solution (Python):

from math import ceil
N = int(input())
A = list(map(int, input().split()))
A.sort()
top = A[-1]
half = ceil(top / 2)
ans = float("inf")
for i in range(N):
    if abs(half - ans) > abs(half - A[i]):
        ans = A[i]
    
print(top, ans)

Solution (Python):

n = int(input())
a = list(map(int,input().split()))
b = max(a)
c = []
h = b/2
for i in range(n):
  c.append([abs(a[i]-h),a[i]])
d = min(c)[1]
print(b,d)

Solution (Python):
def main():
    n = int(input())
    numbers = list(map(int, input().split(" ")))
    numbers.sort()
    if numbers[-1] % 2:
        target = (numbers[-1] + 1) // 2
    else:
        target = numbers[-1] // 2
    answer = 0
    for i in range(n):
        if target <= numbers[i]:
            if i == 0:
                answer = numbers[0]
                break
            elif abs(target - numbers[i]) < abs(target - numbers[i - 1]):
                answer = numbers[i]
                break
            else:
                answer = numbers[i - 1]
                break
    print(numbers[-1], answer)


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
N=int(input())
A=list(map(int,input().split()))
if N==2:
  print(max(A),min(A))
else:
  B=sorted(A)
  a=B[-1]
  B=B[:N-1]
  b=bisect.bisect_left(B,a/2)
  c=abs(a/2-B[b])
  d=abs(a/2-B[b-1])
  if c>d:
    bb=B[b-1]
  else:
    bb=B[b]  
  print(a,bb)

Solution (Python):
def main2():
    N = int(input())
    a = [int(i) for i in input().split()]

    a.sort()
    n = a[-1]
    m = n / 2
    tmp = 10**10
    for i in a:
        if abs(m - i) < tmp:
            tmp = abs(m - i)
            r = i

    print(n, r)


if __name__ == "__main__":
    main2()

Solution (Python):
import bisect

def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    a.sort()
    n = a[-1]
    m = n // 2
    right = bisect.bisect_right(a, m)

    if a[right-1] == m:
        r = m

    else:
        if n % 2 == 0:
            if m - a[right-1] <= a[right] - m:
                r = a[right-1]
            else:
                r = a[right]

        else:
            if m - a[right-1] < a[right] - (m+1):
                r = a[right-1]
            else:
                r = a[right]

    print(n, r)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a_i = max(a)
a.sort(key=lambda x: abs(a_i/2-x))

if a[0] == a_i:
    print(a_i, a[1])
else:
    print(a_i, a[0])

Solution (Python):
import numpy as np

N = int(input())
A = np.array(tuple(map(int, input().split())))
if N == 2:
    print(*A)
else:
    max_A = A.max()
    print(max_A, A[np.abs(A - max_A / 2).argmin()])

Solution (Python):
import bisect

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

a.sort()

idx = bisect.bisect_left(a,a[-1]/2)

if idx == 0:
    print(a[-1],a[idx])
else:
    x,y = a[idx-1],a[idx]
    if y - a[-1]/2 < a[-1]/2 - x:
        print(a[-1],y)
    else:
        print(a[-1],x)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l.pop()
a = m
ans = 0
for r in l:
  if abs((m / 2) - r) < a:
    a = abs((m / 2) - r)
    ans = r
print(m, ans)

Solution (Python):
N = int(input())
A = sorted([int(_) for _ in input().split()])
n = A[-1]

idx = 0
maxv = -1
for i in range(N - 1):
    if A[i] == 0:
        t = 0
    else:
        t = min(n - A[i], A[i])
    if t > maxv:
        maxv = t
        idx = i
print(n, A[idx])

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

m = A[-1]
res, ans = 10**9, 0

for a in A[:n-1]:
    if abs(m/2-a) < res:
        res = abs(m/2-a)
        ans = a

print(m, ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split())) 
a.sort(reverse = True)
hanbun = a[0]/2
sa = []

for i in range(n):
    sa.append(abs(hanbun-a[i]))

num = sa.index(min(sa))
if(num == 0):
    num = 1
'''
print(hanbun)
print(sa)
print(num)
'''
print(a[0], end=' ')
print(a[num])

Solution (Python):
N = int(input())
a = set([int(c) for c in input().split()])
a = sorted(list(a))
X = a[-1]//2+1 if a[-1]%2==1 else a[-1]//2
m = 10**9
x = 0
for i in range(N-1):
  if abs(a[i]-X)<m:
    m = abs(a[i]-X)
    x = i
print(a[-1],a[x])

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

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
A.remove(MA)
SA = sorted(A)

h = MA // 2

da = 10**10
ans = 0
for a in SA:
  diff = abs(a-h)
  if da >= diff:
    da = diff
    ans = a
print(MA, ans)

Solution (Python):

from math import ceil
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
A.sort()
a = A[-1]
ans = ceil(a / 2)
b = float("inf")
for i in range(N-1):
    if abs(b - ans) > abs(A[i] - ans):
        b = A[i]
print(a, b)

Solution (Python):

from math import ceil
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
A.sort()
a = A[-1]
ans = ceil(a / 2)
b = float("inf")
for i in range(N):
    if abs(b - ans) > abs(A[i] - ans):
        b = A[i]
print(a, b)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
l = max(a)
b = l / 2
r = 0
m = 10 ** 9
for i in range(n):
    if abs(a[i] - b) < m:
        m = abs(a[i] - b)
        r = a[i]

if n == 2:
    print(a[0], a[1])
else:
    print(l, r)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 main():
    N = I()
    A = sorted(LI())
    n = A[-1]
    ix = bisect.bisect_left(A, n / 2)
    '''
    [1, 3, 8, 10, 12] -> bisect_left(A, 12 / 2) = 2
    [1, 2, 3, 8, 10, 12] -> bisect_left(A, 12/2) = 3
    '''
    m, l, r = inf, inf, inf
    
    if ix < N:
        m = A[ix]
    if 0 < ix <= N:
        l = A[ix - 1]

    m1 = abs(n / 2 - m)
    l1 = abs(n / 2 - l)

    min_val = min(m1, l1)
    if min_val == m1:
        n_ = m
    if min_val == l1:
        n_ = l

    print(n, n_)
main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 main():
    N = I()
    A = sorted(LI())
    n = A[-1]
    ix = bisect.bisect_left(A, n / 2)
    '''
    [1, 3, 8, 10, 12] -> bisect_left(A, 12 / 2) = 2
    [1, 2, 3, 8, 10, 12] -> bisect_left(A, 12/2) = 3
    '''
    m, l, r = inf, inf, inf
    
    if ix < N:
        m = A[ix]
    if 0 < ix <= N:
        l = A[ix - 1]
    if ix + 1 < N:
        r = A[ix + 1]

    m1 = abs(n / 2 - m)
    l1 = abs(n / 2 - l)
    r1 = abs(n / 2 - r)

    min_val = min(m1, l1, r1)
    if min_val == m1:
        n_ = m
    if min_val == l1:
        n_ = l
    if min_val == r1:
        n_ = r

    print(n, n_)
main()

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

m = a[-1]
r = min(a, key = lambda x: abs((m-x)-x))
print(m, r)

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

m = a[-1]
r = sorted(a[:-1], key = lambda x: abs((m-x)-x))[0]
print(m, r)

Solution (Python):
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = abs(M - x - x)
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))

Solution (Python):
import bisect
s = int(input())
a = list(map(int, input().split()))
aa = sorted(a)
v = 0
m = aa[-1]
x = bisect.bisect_left(aa,m//2)
if abs(aa[x-1]) > abs(m-aa[x]):
	b = aa[x-1]
else:
	b = aa[x]
if aa[x] == m:
	x -= 1
	b = aa[x]
print (m,b)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
k = max(a)
b = [0] * n
for i in range(n):
    if a[i] == k:
        b[i] = k
    else: b[i] = abs(a[i]-k/2)
r = a[b.index(min(b))]
print(k, r)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ai = max(A)
    mi = float("inf")
    aj = 0
    for a in A:
        if ai == a:
            continue
        tmp = mi
        mi = min(mi, abs((ai - a) - a))
        if tmp != mi:
            aj = a

    print(ai, aj)

    

if __name__ == '__main__':
    main()

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

a.sort(reverse=True)

n = a[0]
r = -1
t = a[0]
for aa in a[1:]:
    if abs(n/2-aa) <= t:
        r = aa
        t = abs(n/2-aa)

print(n, r)

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(n: int, a: "List[int]"):
    a.sort(reverse=True)
    r0 = a[0]
    r1 = a[1]
    h = r0 // 2
    for v in a[1:]:
        if abs(v - h) < abs(r1 - h):
            r1 = v
    print(r0, r1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(n)]  
    solve(n, a)

if __name__ == '__main__':
    main()

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

if n == 2:
    a = sorted(a)
    print(a[1], a[0])
    exit()

max_a = max(a)
M = max_a // 2
min_diff = float('inf')
r = 0
for i in range(n):
    if abs(a[i] - M) < min_diff:
        min_diff = abs(a[i] - M)
        r = a[i]

print(max_a, r)

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

n = A[0]
m = n/2
c = 1e100
for a in A[1:]:
    if abs(m-a) < abs(m-c):
        c = a

print(n, c)

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

A.sort()

m = A[-1] / 2
diff = abs(A[0] - m)
r = A[0]
for a in A:
    tmp = abs(a - m)
    if tmp < diff:
        diff = tmp
        r = a

print(int(2 * m), r)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
max_a = max(a)
del a[-1]
target = int(1e9+1)
for aa in a:
    if abs(max_a - target*2) >= abs(max_a - aa*2):
        target = aa
print(max_a, target)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)[::-1]
ans=a[1]
tmp=0
for i in range(1,n):
    if a[0]-a[i]>a[0]-(a[0]-a[i]):
        m=a[0]-a[i]
    else:
        m=a[i]
    if tmp<abs(a[0]-m):
        tmp=abs(a[0]-m)
        ans=a[i]
print(a[0],ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
n = max(A)
tmp = 0
ans = -1
for i in range(N):
	if min(A[i], n-A[i]) >= tmp:
		tmp = min(A[i], n-A[i])
		ans = A[i]

print(n, ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.sort()
dis = l[-1]
if l[-1]% 2 == 0:
    right = l[-1]//2
else:
    right = l[-1]//2+1
for i in range(n-1):
    if abs(l[i]-right) <= dis:
        dis = abs(l[i]-right)
        check = i
print("{} {}".format(l[-1],l[check]))

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

A.sort()
i = A[-1]
middle = i/2
j_right = bisect.bisect_right(A, middle)
left = A[j_right - 1]
right = A[j_right]
if abs(middle - left) <= abs(middle - right):
    j = left
else:
    j = right
print(i, j)

Solution (Python):
def solve(n, A):
    m = max(A)
    r = 0
    for a in A:
        if abs(m / 2 - r) > abs(m / 2 - a):
            r = a
    return (m, r)

_n = int(input())
_A = list(map(int, input().split()))
print(*solve(_n, _A))

Solution (Python):


import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        n0 = max(A)

        mid, r, cur = n0 / 2, -1, float("inf")
        for i in A:
            if i != n0:
                x = abs(mid - i)
                if x < cur:
                    r, cur = i, x
        return n0, r

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
max_val = max(A)
half = max_val // 2
r = None
diff = float('inf')
for a in A:
    d = abs(half - a)
    if d < diff and a != max_val:
        diff = d
        r = a
print(max_val, r)

Solution (Python):
n = int(input())
a = sorted([int(i) for i in input().split()])
a_i = (a[-1]+1)//2
ans = 0
for i in range(n):
    while abs(a_i - a[i]) < abs(a_i - ans):
        ans = a[i]
print(a[-1]," ",ans)

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

a.sort()
now = 1e18
ans = 0
for r in a:
    d = abs(r - a[n - 1] / 2)
    if d < now:
        ans = r
        now = d
print(a[n-1], ans)

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

max_a = max(a_list)
half_max = max_a / 2

near = max_a
near_ori = max_a
for a in a_list:
    if a == max_a:
        continue
    tmp = abs(a - half_max)
    if tmp < near:
        near = tmp
        near_ori = a
        
print(max_a, near_ori)

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

n = A[-1]
r_val = -float('inf')
r_row = None
for idx in range(N - 1):
    if r_val < min(n - A[idx], A[idx]):
        r_val = min(n - A[idx], A[idx])
        r_row = A[idx]
print(n, r_row)

Solution (Python):

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

m = lst[-1]
line = m / 2
r = 10**10
for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

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

ma = a[-1]

*b, = sorted((min(x, ma - x), x) for x in a[:-1])
_, r = b[-1]

print(ma, r)

"""
cmb(12,6) > cmb(12,5) > cmb(11,5)

cmb(n,r) = cmb(n-1,r) + cmb(n-1,r) > cmb(n-1,r)
rを決めたとき、nはできるだけ大きい方がよい=ma

cmb(ma,r)で最大となるもの
r=ma//2
"""

Solution (Python):
N = int(input())
A = sorted(map(int, input().split()))
ai = A[-1]
aj = min(A, key=lambda a: max(a,ai-a))
print(ai, aj)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
n = A[0]
r = A[1]
for a in A[1:]:
    if abs((n/2)-r) > abs((n/2)-a):
        r = a
print(n,r)

Solution (Python):
n = int(input())
a = set(map(int, input().split()))
x = max(a)
z = 10 ** 9
for i in a:
    if abs(i - x / 2) < z:
        y = i
        z = abs(i - x / 2)
print(x, y)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
x = a.pop(-1)
x2 = x/2
ans = a[0]
t = abs(x2-ans)
for i in a:
  if abs(x2-i) < t:
    ans = i
    t = abs(x2-ans)
print(x,ans)

Solution (Python):
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
ans = []
for i in range(1,N):
    candind = bisect.bisect_left(a,a[i]/2)
    if candind == i:
        candind -= 1
        cand = a[candind]
    elif candind == 0:
        cand = a[candind]
    else:
        if a[candind]-a[i]/2 <= a[i]/2-a[candind-1]:
            cand = a[candind]
        else:
            cand = a[candind-1]
    ans.append([a[i],cand])
ans.sort()
print(*ans[-1])

Solution (Python):
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
ans = []
for i in range(1,N):
    candind = bisect.bisect_left(a,a[i]/2)
    if candind == i:
        candind -= 1
        cand = a[candind]
    elif candind == 0:
        cand = a[candind]
    else:
        if a[candind]-a[i]/2 <= a[i]/2-a[candind-1]:
            cand = a[candind]
        else:
            cand = a[candind-1]
    ans.append([a[i],cand])
ans.sort(reverse=True)
x1 = ans[0][1]
ans2 = [ans[0]]
for i in range(1,len(ans)):
    if x1 >= ans[i][1]:
        break
    ans2.append(ans[i])
    x1 = ans[i][1]
print(*ans2[-1])

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
n = a[-1]
diff = 10**18
r = -1

for ai in a:
    if abs(n-2*ai)<diff:
        diff = abs(n-2*ai)
        r = ai

print(n, r)

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

x = max(A)

d = 10**18
for a in A:
    if a == x:
        continue
    tmp = abs(x/2-a)
    if tmp < d:
        d = tmp
        y = a

print(x, y)

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
def getNearestValue(list, num):
	idx = np.abs(np.asarray(list) - num).argmin()
	return list[idx]

N=int(input())
A=list(map(int,input().split()))
A.sort()
n=A.pop()
r=getNearestValue(A,n/2)



print(n,r)

Solution (Python):
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))

a.sort()
m = a[-1] // 2 + a[-1] % 2

i = bisect_left(a, m)

if i == 0:
    ans = str(a[-1]) + " " + str(a[0])
elif i == len(a)-1:
    ans = str(a[-1]) + " " + str(a[-2])
else:
    k = [a[i] - m, m - a[-1] % 2 - a[i-1]]
    s = min(k)
    s = k.index(s)
    ans = str(a[-1]) + " " + str(a[i-s])     

print(ans)