let min_with f x y = if f x <= f y then x else y
 
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let ai = Array.fold_left max min_int as_ in
  let aj = Array.fold_left (min_with (fun a ->
    if a = ai then max_int
    else if ai mod 2 = 0 then abs (a - ai / 2)
    else if a <= ai / 2 then ai / 2 - a
    else a - (ai + 1) / 2)) ai as_ in
  Printf.printf "%d %d\n" ai aj