Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)

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

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

aa.sort()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

import bisect
ans=0
(a,b)=(0,0)

for item in aa[:n//2+1]:
    i=bisect.bisect_left(aa,item*2)
    tmp=cmb(aa[min(n-1,i)],item,p)
    #print(aa[min(n-1,i)],item,tmp)
    if ans<tmp:
        ans=tmp
        (a,b)=(aa[min(n-1,i)],item)
    

print(a,b)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

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

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

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)


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

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#cmb(n-1, pair, p)

result=0
for i in range(1,len(a)):
    if a[i-1]<nn//2 and a[i]>=nn//2:
        if a[i]==nn:
            print(nn,a[i-1])
            exit()
        if cmb(nn,a[i-1],1)>cmb(nn,a[i],1):
            print(nn,a[i-1])
        else:
            print(nn,a[i])

        exit()
  
  


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

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

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

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#cmb(n-1, pair, p)

result=0
for i in range(1,len(a)):
    if a[i-1]<nn//2 and a[i]>=nn//2:
        if a[i]==nn:
            print(nn,a[i-1])
            exit()
        if cmb(nn,a[i-1],1)>cmb(nn,a[i],1):
            print(nn,a[i-1])
        else:
            print(nn,a[i])

        exit()
  
  


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

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

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

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)