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

import bisect, math
def comb(n,r):
  return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))
  
arg_max_i = bisect.bisect_left(a, a[n-1] // 2)

if comb(a[n-1], a[arg_max_i]) < comb(a[n-1], a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])


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

import bisect

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

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])

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


mid_dis = [abs(a[n-1] / 2 - a[i]) for i in range(n-1)]
arg_max_i = [i for i in range(n-1) if mid_dis[i] == min(mid_dis)][0]

print(a[n-1], a[arg_max_i])

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

import bisect

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

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])

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

import math
def comb(n,r):
  return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))
  
mid_dis = [abs(a[n-1] / 2 - a[i]) for i in range(n-1)]
arg_max_i = [i for i in range(n-1) if mid_dis[i] == min(mid_dis)][0]

print(a[n-1], a[arg_max_i])


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

import bisect

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

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])

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

import math
def comb(n,r):
  return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))
  
max_comb = [comb(i, i // 2) for i in range(n-1)]

mid_dis = [abs(a[n-1] / 2 - a[i]) for i in range(n-1)]
arg_max_i = [i for i in range(n-1) if mid_dis[i] == min(mid_dis)][0]

print(a[n-1], a[arg_max_i])


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

import bisect

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

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])

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

import math
def comb(n,r):
  return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))
  
max_comb = [comb(i, i // 2) for i in range(n-1)]

mid_dis = [abs(a[n-1] / 2 - a[i]) for i in range(n-1)]
arg_max_i = [i for i in range(n-1) if mid_dis[i] == min(mid_dis)][0]

print(a[n-1], a[arg_max_i])

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

import bisect

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

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])