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 numpy as np


def nearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


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

ans1 = max(a)  
if n == 2:
    ans2 = min(a)
else:
    ans2 = nearestValue(a, ans1/2)

print('{0} {1}'.format(ans1, ans2))

Solution (Python):
import numpy as np

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

a_max = max(a)
a_max_index = np.argmax(a)

del a[a_max_index]

center = a_max / 2

a_x_index = np.argmin(np.absolute(np.array(a) - center))
a_x = a[a_x_index]

print(str(a_max) + ' ' + str(a_x))

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

b = max(a)
c = 1 << 10
for i in a:
    if abs(b // 2 - c) > abs(b // 2 - i) and i != b:
        c = i

print("{} {}".format(b, c))

Solution (Python):
n = int(input())
l = list(map(int, input().split(' ')))
sorted_l = sorted(l)

max_ = sorted_l[-1]
med = sorted_l[-1] / 2

left = 0
right = n - 1
while left < right:
    m = int((left + right) // 2)
    
    if sorted_l[m] < med:
        left = m + 1
    else:
        right = m

median = sorted_l[m]
if (m + 1 < n and (abs(sorted_l[m + 1] - med) < abs(median - med))):
    median = sorted_l[m + 1]

if (0 < m - 1 and (abs(sorted_l[m - 1] - med) < abs(median - med))):
    median = sorted_l[m - 1]

if n == 2:
    print(max_, sorted_l[0])
else:
    print(max_, median)

Solution (Python):
import math

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = max(a)
a.remove(x)
maxi = 0
mind = x
for i in range(len(a)):
    d = abs((x+1) // 2 - a[i])
    if d < mind:
        maxi = i
        mind = d
print(str(x) + ' ' + str(a[maxi]))

Solution (Python):
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
l, r = 0, 0
l = max(a)
a.remove(l)
j = bisect.bisect_left(a, l/2)
try:
    if abs((l/2) - a[j-1]) < abs((l/2) - a[j]):
        j -= 1
except:
    pass
print(l, a[min(j, len(a)-1)])

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    t = max(a)
    m = -1
    r = -1
    for c in a:
        if min(c,t-c) > m and c != t:
            r = c
            m = min(c,t-c)

    return '{} {}'.format(t,r)


print(main())

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = max(a)
a.remove(i)
j = min(a, key=lambda x: abs(i-x*2))
print(i, j)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = max(a)
a.remove(i)
j = min(a, key=lambda x: abs(i/2-x))
print(i, j)

Solution (Python):
import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 10000000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma-num*2)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])

Solution (Python):

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

n = A[-1]
r = sorted(A[:-1], key=lambda x: abs(x-n/2))[0]
print(n, r)

Solution (Python):
count = int(input())
li = list(map(int, input().split()))

sli = sorted(li)

pair_a = sli[len(sli) - 1]
pair_b = 0
current_max = 0

i = sli[len(sli) - 1]

diff = 10**9
for j in range(0, len(sli) - 1):
    h = pair_a / 2
    if abs(h - sli[j]) < diff:
        diff = abs(h - sli[j])
        pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))

Solution (Python):
from bisect import bisect

n = int(input())

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

a = A[-1]

i = bisect(A,a/2)
j = max(i-1,0)

k = min((A[i]-a/2, i),(a/2-A[j],j))[1]

print(a,A[k])

Solution (Python):
N = int(input())
src = list(map(int,input().split()))
n = max(src)

d = n+1
r = min(src)
for a in src:
    if a == n: continue
    if abs(n - a*2) < d:
        d = abs(n - a*2)
        r = a
print(n, r)

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

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))

Solution (Python):
import bisect

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

As.sort()
maxA = As[-1]

i = bisect.bisect_right(As, maxA / 2)
if i == n - 1:
    i = i - 1
elif i > 0:
    if maxA / 2 - As[i - 1] < As[i] - maxA / 2:
        i = i - 1

print(maxA, As[i])

Solution (Python):
import numpy as np
import itertools

N = int(raw_input())
A = map(int, raw_input().split())

def mul(x, y):
    return x * y

def nCr(n, r):
    print n, r
    if r == 0:
        return 1
    if n/2 < r:
        return nCr(n, n-r)
    print range(n, n - r, -1), range(1, r+1)
    return np.prod(range(n, n - r, -1)) / np.prod(range(1, r+1))

def nCrMax(n):
    return nCr(n, n/2)

sortedA = sorted(A, reverse = True)

max = -1
for i in range(N - 1):
    n = sortedA[i]
    target = n/2
    newA = sortedA[:i] + sortedA[i+1:]
    r = newA[np.argmin(map(lambda x: abs(x - target), newA))]
    
    
    
    
    
    
    
    break
    
print n, r

Solution (Python):
import numpy as np

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

M = np.max(n_list)
mid_M = M / 2
ex_M_list = list(n_list)
ex_M_list.remove(M)

best_k_cand = list(abs(ex_M_list - mid_M))
best_k = min(best_k_cand)
a = best_k_cand.index(best_k)

print(M, ex_M_list[a])

Solution (Python):

 
import bisect
from scipy.misc import comb
 
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
b = a.pop()
ind = bisect.bisect_left(a, b/2)

if ind == n-1:
    c = a.pop()
elif ind == 0:
    c = a[0]
else:
    if b/2 - a[ind-1] < a[ind] - b/2:
        c = a[ind-1]
    else:
        c = a[ind]

print(b, c)

Solution (Python):
n = int(input())
p = list(map(int,input().split()))
p.sort()
a1 = max(p)
a2 = min(p)
half = (a1+1) // 2
s = n // 2
graph = [0] * n

while True:
    if graph[s] != 0:
        break
    else:
        graph[s] += 1
    if p[s] <= half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s += 1
    elif p[s] > half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s -= 1
    if s == 0 or s == n:
        break
print(a1, a2)

Solution (Python):
import bisect


def get_closest(nums, target):
    pos = bisect.bisect_left(nums, target)
    if pos == 0:
        return nums[0]
    if pos == len(nums):
        return nums[-1]

    before = nums[pos - 1]
    after = nums[pos]

    if target in [before, after]:
        return target

    if after - target < target - before:
        return after
    else:
        return before


n = int(raw_input())
nums = map(int, raw_input().split())

nums = sorted(nums)
top = nums[-1]
nums.remove(top)

if top % 2 == 0:
    optimal = top / 2
    bottom = get_closest(nums, optimal)
else:
    res1 = get_closest(nums, top / 2)
    res2 = get_closest(nums, (top + 1) / 2)

    if abs(res1 - (top/2)) < abs(res2 - ((top + 1) / 2)):
        bottom = res1
    else:
        bottom = res2

print "{} {}".format(top, bottom)

Solution (Python):
f = lambda :[int(i) for i in input().split()]
from sys import stderr
f = lambda :[int(i) for i in input().split()]
from functools import reduce
from operator import add
debug = lambda *x:stderr.write(reduce(add,repr(x))+'\n')

num = int(input())
a = f()
a.sort()

n = a[-1]
half = int(n/2)
r = a[0]
for po in a:
    if abs(half - po) < abs(half - r) or (r == half - 1 and po == r + 2):
        r = po
print(n,r)

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

l0 = sorted(l0)
m = l0.pop()

mini = m + 1
maxii = 0
ans = 0
for i in range(len(l0)):
    if l0[i] < m/2:
        ipred = l0[i]
        continue
    if abs((m/2 - l0[i-1])) >= abs((m/2 - l0[i])):
        ans = m, l0[i]
    else:
        ans = m, l0[i-1]
    break

if not ans:
    print(m, ipred)
else:
    for i in ans:
        print(i, end=' ')

Solution (Python):

"""
Contents   : AtCoder Regular Contest 095 d問題
Author     : Kitaura Hiromi
LastUpdate : 20180414
Since      : 20180414
"""





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

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

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

sa = np.sort(A)
max_num = sa[-1]
sa = sa[:-1]

min_num = sa[np.abs(sa-((max_num+1)//2)).argmin()]
print(max_num, min_num)

Solution (Python):


import copy

n = int(raw_input())
a = map(int,raw_input().split())

ai = max(a)
a_new = copy.copy(a)

a_new.remove(ai)

aj = a_new[0]
ai_half = ai/2
for i in range(n-1):
    if abs(a_new[i] - ai_half) < abs(aj - ai_half):
        aj = a_new[i]

print ai,aj

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
M = max(a)
a.remove(M)
for i in range(n - 1):
    if a[i] > M / 2:
        if a[i] - M / 2 <= M / 2 - a[i - 1]:
            print(M, a[i])
            break
        else:
            print(M, a[i - 1])
            break
else:
    print(M, a[-1])

Solution (Python):
def main():
    N = int(input())

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

    n = max(A)
    A.remove(n)

    tmp = []
    for a in A:
        
        
        
        
        tmp.append((max(a, n - a), a))
    print(n, min(tmp)[1])


if __name__ == '__main__':
    main()

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

a1 = max(p)
a2 = min(p)
half = (a1+1) // 2
s = n // 2
graph = [0] * n

while True:
    if graph[s] != 0:
        break
    else:
        graph[s] += 1
    if p[s] < half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s += 1
    elif p[s] > half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s -= 1
    else:
        a2 = p[s]
        break
    if s == 0 or s == n:
        break
print(a1, a2)

Solution (Python):
import numpy as np


def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

n = int(input())
a = list(map(int, input().split()))
a.sort()
max = max(a)
min = getNearestValue(a,max/2)

if max == min:
    print(max, getNearestValue(a[:n-1], max / 2))
else:
    print(max,getNearestValue(a,max/2))

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

maxv = max(arr)
half = maxv/2
mindelta = float('inf')
ans = None
for i in range(N):
  if arr[i] == maxv:
    continue
  delta = abs(arr[i] - half)
  if delta < mindelta:
    mindelta = delta
    ans = arr[i]
print(maxv, ans)

Solution (Python):
from bisect import *

def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError

def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    try:
        if i:
            return a[i-1]
    except:
        return -1

def find_le(a, x):
    'Find rightmost value less than or equal to x'
    i = bisect_right(a, x)
    try:
        if i:
            return a[i-1]
        else:
            return -1
    except:
        return -1

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect_right(a, x)
    try:
        if i != len(a):
            return a[i]
    except:
        return -1

def find_ge(a, x):
    'Find leftmost item greater than or equal to x'
    i = bisect_left(a, x)
    try:
        if i != len(a):
            return a[i]
        else:
            return -1
    except:
        return -1

def fun(a,b):
    if b==-1:
        return -1
    elif b==0:
        return 0
    return (b+1)*(2*a-b)/2 - b*(b+1)/2

N=int(raw_input())
X=map(int, raw_input().split())
Y=sorted(X)
ans=[-1,0,0]
if len(Y)==2:
    print Y[1],Y[0]

else:
    for y in Y[::-1]:
        qry=y/2
        tmp1=find_ge(Y, qry)
        tmp2=find_le(Y, qry)
        if ans[0]<fun(y,tmp1):
            ans=[fun(y,tmp1),y,tmp1]
        if ans[0]<fun(y,tmp2):
            ans=[fun(y,tmp2),y,tmp2]
    print ans[1], ans[2]

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

ans1 = max(a)
a.remove(ans1)
key = ans1
m = 0
for i in range(n - 1):
    if abs(a[i] - ans1 // 2) < key:
        key = abs(a[i] - ans1 // 2)
        m = i

print(ans1,end=" ")
print(a[m])

Solution (Python):
import sys
from collections import Counter
import random
import numpy as np

def fact(n):
    x=1
    for i in range(2,n+1):x*=i
    return x

def comb(n,r):
    return(fact(n)//(fact(r)*fact(n-r)))

n=int(input())
a=list(map(int,input().split()))
a.sort()
z=a.pop(n-1)

min=10**10
y=z/2
x=0
for i in range(n-1):
    dif=abs(y-a[i])
    if(dif<min):
        min=dif
        x=a[i]
print(z,x)

Solution (Python):
import math

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

a.sort()

ai = a[n-1]
mid = ai/2
diff = ai
aj = 0

for i in range(n-1):
    if abs(a[i] - mid) < diff:
        aj = a[i]
        diff = abs(a[i]-mid)

print(ai,aj)

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
x=max(a)
y=float("inf")
for i in range(n):
 if x!=a[i] and abs(y-x//2)>abs(a[i]-x//2):
    y=a[i]
print(x,y)

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

i = A.argmax()
j = 0
if i == 0:
    j = 1

for n in range(1, N):
    if j == i:
        continue

    if abs(A[i]/2 - A[n]) < abs(A[i]/2 - A[j]):
        j = n

print(A[i], A[j])

Solution (Python):

from math import *

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

n = A[-1]

score_max = 0
r = A[0]
for i in range(1, N-1):
    score = min(A[i], n-A[i])
    if score_max < score:
        score_max = score
        r = A[i]
    else:
        break

print(n, r)

Solution (Python):

def main():
    input()
    xx = list(map(int, input().split()))
    xx.sort()
    a = xx.pop()
    b = max(xx, key=lambda x: min(x, a - x))
    print(a, b)


if __name__ == '__main__':
    main()

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

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

a=max(nums)

nums[nums.index(a)]=-1
diffs=[abs(2*num-a) for num in nums]
min_diff=min(diffs)

b=nums[diffs.index(min_diff)]

print(a,b)

Solution (Python):
input()
aa = sorted(list(map(int, input().split())))
n = aa[-1]
r = aa[0]
d = abs(n-2*r)
for a in aa[:-1]:
    td = abs(n-2*a)
    if td < d:
        r = a
        d = td
print(n, r)

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
a1 = a[n-1]
b = sorted([(abs(a[i] - a1/2),a[i], i) for i in range(n)])
a2 = a[b[0][2]]
print(a1, a2)

Solution (Python):

from bisect import bisect, bisect_left 
def inpl(): return list(map(int, input().split()))

N = int(input())
A = sorted(inpl())

n = A[-1]

l = A[max(bisect(A, n/2)-1, 0)]
r = A[bisect_left(A, n/2)]

if abs(n/2-l) < abs(r-n/2) or r==n:
    print(n, l)
else:
    print(n, r)

Solution (Python):



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

a=sorted(C)

M=a[-1]


A=sorted([abs(2*i - M) for i in a])



N1= (-A[0]+M)//2
N2= (A[0]+M)//2

j = C.index(M)
if N1 in a:
    print(M,N1)
else:
    print(M,N2)

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

a = list(sorted(a))
j = 0
for i in range(1, n - 1):
    if abs(a[-1] - 2 * a[i]) < abs(a[-1] - 2 * a[j]):
        j = i
print("%d %d" % (a[-1], a[j]))

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

def p(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x

def comb(n, r):
    return p(n) // p(n - r) // p(r)

xs = sorted(A)

m1 = xs[-1]
m0 = m1 / 2

ys = sorted(xs, key=lambda x:abs(x-m0))
print(m1, ys[0])

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
N=a[n-1]
Kindex=0
K=a[Kindex]
M=10**9
for i in range(n-2):
    if abs(2*a[i]-N)<=M:
        Kindex=i
        M=abs(2*a[i]-N)
print(N,a[Kindex])

Solution (Python):
n=int(raw_input())
a=map(int,raw_input().split())
a.sort()
s=a[0]
from math import fabs
for i in range(n-1):
	if fabs(a[n-1]/2.0-a[i])<fabs(a[n-1]/2.0-s):
		s=a[i]
print a[n-1],s

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    n = f.read_int()
    a = f.read_int_list()

    i = max(a)
    a.remove(i)
    j = sorted(a, key=lambda x: abs(x*2-i))[0]

    return "%d %d"%(i,j)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
y = a[-1]
m = None
x = None
for i in range(n - 1):
    k = a[i]
    l = max(k, y - k)
    if m is None or m > l:
        m = l
        x = k
print(y, x)

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

a.sort()
large = a.pop()

min_val =  0
for i in a:
    min_val =  max(min_val, min(i,large-i)
                   )

if min_val in a:
    print(large , min_val)
else:
    print(large, large-min_val)

Solution (Python):
import bisect

n = int(input())
aaa = list(map(int, input().split()))
aaa.sort()
m = aaa[-1]
ri = bisect.bisect(aaa, m // 2)
if ri == 0:
    print(m, aaa[0])
else:
    r1, r2 = aaa[ri - 1], aaa[ri]
    d1 = m - 2 * r1
    d2 = 2 * r2 - m
    if d1 <= d2:
        print(m, r1)
    else:
        print(m, r2)

Solution (Python):

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

p = max(a_list)
gap = p
q = p
for i in range(n):
    gap_ = abs(a_list[i] - p / 2)
    if gap_ < gap and a_list[i] != p:
        gap = gap_
        q = a_list[i]
print(" ".join([str(p), str(q)]))

Solution (Python):
N = int(input())
*A, = map(int, input().split())
A.sort()
n = A[-1]
k = 0
for a in A[:-1]:
    if k < min(a, n-a):
        k = a
print(n, k)

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

for i in range(N-1):
  r = n/2 - a[i]
  if abs(r) < abs(k): k = r

print(n,int(n/2-k))

Solution (Python):
n = input()
a = map(int, raw_input().split())
x = max(a)
y = a[0]
for t in a:
  if t != x and min(x-t, t) >= min(x-y, y):
    y = t
print x, y

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
m = max(a)
best = m
y = -1
for x in a:
    if x == m: continue
    if abs(x - m / 2) < best:
        best = abs(x - m / 2)
        y = x
print(m, y)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    xs = [int(x) for x in input().split()]

    c = max(xs)
    sc, best = c, c
    for d in xs:
        if d == c:
            continue
        if abs(d - c / 2) < sc:
            sc = abs(d - c / 2)
            best = d
    print(c, best)