Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
import statistics

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
ans = (0, 0)
AL = 0
A.remove(MA)
upper = statistics.median_high(A)
lower = statistics.median_low(A)

r1 = math.factorial(MA) // (math.factorial(MA-upper) * math.factorial(upper))
r2 = math.factorial(MA) // (math.factorial(MA-lower) * math.factorial(lower))

if upper == lower:
  print(MA, upper)
  exit()
  
if r1 > r2:
  print(MA, upper)
else:
  print(MA, lower)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
import statistics

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
A.remove(MA)
SA = sorted(A)

h = MA // 2

da = 10**10
ans = 0
for a in SA:
  diff = abs(a-h)
  if da >= diff:
    da = diff
    ans = a
print(MA, ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
ans = (0, 0)
AL = 0
for i in A:
  if i == MA:
    continue
  r = math.factorial(MA) // (math.factorial(MA-i) * math.factorial(i))
  if AL < r:
    AL = r
    ans = (MA, i)
    
print(ans[0], ans[1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
import statistics

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
A.remove(MA)
SA = sorted(A)

h = MA // 2

da = 10**10
ans = 0
for a in SA:
  diff = abs(a-h)
  if da >= diff:
    da = diff
    ans = a
print(MA, ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
ans = (0, 0)
AL = 0
for i in A:
  if i == MA:
    continue
  r = math.factorial(MA) // (math.factorial(MA-i) * math.factorial(i))
  if AL < r:
    AL = r
    ans = (MA, i)
    
print(ans[0], ans[1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
import statistics

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
A.remove(MA)
SA = sorted(A)

h = MA // 2

da = 10**10
ans = 0
for a in SA:
  diff = abs(a-h)
  if da >= diff:
    da = diff
    ans = a
print(MA, ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

ans = (0, 0)
AL = 0
for i in A:
  for j in A:
    if i == j:
      continue
    if i < j:
      continue
    r = math.factorial(i) // (math.factorial(i-j) * math.factorial(j))
    if AL < r:
      AL = r
      ans = (i, j)
    
print(ans[0], ans[1])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
import statistics

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
A.remove(MA)
SA = sorted(A)

h = MA // 2

da = 10**10
ans = 0
for a in SA:
  diff = abs(a-h)
  if da >= diff:
    da = diff
    ans = a
print(MA, ans)