Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))
from functools import lru_cache

import math

@lru_cache(maxsize=None)
def combi(n,r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

max_combi = 0
l=0
for r in range(1,n):

    while a[l] <= (a[r]+1)//2:
        l+=1
    l-=1
    
    c = combi(a[r], a[l])
    if c > max_combi:
        max_combi = c
        x,y = a[r], a[l]

print(x,y)


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

import bisect

mid = (a[-1]+1)//2
mid_idx = bisect.bisect_left(a, mid)

if abs(mid - a[mid_idx-1]) <= abs(a[mid_idx] - mid):
    print(a[-1], a[mid_idx-1])
else:
    print(a[-1], a[mid_idx])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))
from functools import lru_cache

import math

@lru_cache(maxsize=None)
def combi(n,r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

max_combi = 0
l=0
for r in range(1,n):

    while a[l] <= (a[r]+1)//2:
        l+=1
    l-=1
    
    c = combi(a[r], a[l])
    if c > max_combi:
        max_combi = c
        x,y = a[r], a[l]

print(x,y)


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

import bisect

mid = (a[-1]+1)//2
mid_idx = bisect.bisect_left(a, mid)

if abs(mid - a[mid_idx-1]) <= abs(a[mid_idx] - mid):
    print(a[-1], a[mid_idx-1])
else:
    print(a[-1], a[mid_idx])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

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

max_combi = 0
l=0
for r in range(1,n):

    while a[l] <= (a[r]+1)//2:
        l+=1
    l-=1
    
    c = combi(a[r], a[l])
    if c > max_combi:
        max_combi = c
        x,y = a[r], a[l]

print(x,y)


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

import bisect

mid = (a[-1]+1)//2
mid_idx = bisect.bisect_left(a, mid)

if abs(mid - a[mid_idx-1]) <= abs(a[mid_idx] - mid):
    print(a[-1], a[mid_idx-1])
else:
    print(a[-1], a[mid_idx])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

import math
def combi(n,r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
from bisect import bisect_left

max_combi = 0
l=0
r=1
for i in range(1,n):
    idx = bisect_left(a, (a[i]+1)//2)
    if a[idx] > (a[i]+1)//2:
        idx -= 1
    c = combi(a[i], a[idx])
    if c > max_combi:
        max_combi = c
        x,y = a[i], a[idx]

print(x,y)


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

import bisect

mid = (a[-1]+1)//2
mid_idx = bisect.bisect_left(a, mid)

if abs(mid - a[mid_idx-1]) <= abs(a[mid_idx] - mid):
    print(a[-1], a[mid_idx-1])
else:
    print(a[-1], a[mid_idx])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

import math
def combi(n,r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
from bisect import bisect_left

max_combi = 0
for i in range(1,n):
    idx = bisect_left(a[:i], (a[i]+1)//2)
    if a[idx] > (a[i]+1)//2:
        idx -= 1
    c = combi(a[i], a[idx])
    if c > max_combi:
        max_combi = c
        x,y = a[i], a[idx]

print(x,y)

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

import bisect

mid = (a[-1]+1)//2
mid_idx = bisect.bisect_left(a, mid)

if abs(mid - a[mid_idx-1]) <= abs(a[mid_idx] - mid):
    print(a[-1], a[mid_idx-1])
else:
    print(a[-1], a[mid_idx])