Buggy python submission (verdict: Time Limit Exceeded):
def comb(n,r):
    r=min(r,n-r)
    h,k=1,1
    for i in range(1,r+1):
        h*=(n-r+i)
        k*=i
    return h//k
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-1),min(n,l[-1]//2+2)):
    g=comb(mm,l[i])
    if ans<g:
        ans=g
        p=i
print(mm,l[p])


Fixed submission:
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])

Buggy python submission (verdict: Time Limit Exceeded):
def comb(n,r):
    r=min(r,n-r)
    h,k=1,1
    for i in range(1,r+1):
        h*=(n-r+i)
        k*=i
    return h//k
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    g=comb(mm,l[i])
    if ans<g:
        ans=g
        p=i
print(mm,l[p])


Fixed submission:
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])

Buggy python submission (verdict: Runtime Error):
from scipy import special
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    g=scipy.special.comb(mm, l[i], exact = False)
    if ans<g:
        ans=g
        p=i
print(mm,l[p])

Fixed submission:
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])

Buggy python submission (verdict: Time Limit Exceeded):
def comb(n,r):
    r=min(r,n-r)
    h,k=1,1
    for i in range(1,r+1):
        h*=(n-r+i)
        k*=i
    return h//k
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if ans<comb(mm,l[i]):
        ans=comb(mm,l[i])
        p=i
print(mm,l[p])

Fixed submission:
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])

Buggy python submission (verdict: Time Limit Exceeded):
def comb(n,r):
    r=min(r,n-r)
    h,k=1,1
    for i in range(1,r+1):
        h*=(n-r+i)
        k*=i
    return h//k
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
mm=l[-1];ans=0;p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if ans<comb(mm,l[i]):
        ans=comb(mm,l[i])
        p=i
print(mm,l[p])

Fixed submission:
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
l=list(map(int,input().split()))
l.sort()
pre=10**9
mm=l[-1];p=0
for i in range(max(0,bl(l,l[-1]//2)-2),min(n,l[-1]//2+3)):
    if abs(mm/2-l[i])<pre:pre=abs(mm/2-l[i]);p=i
print(mm,l[p])