let () =
    let _ = read_int () in
    let a =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    let max :: max2 :: _ = List.sort (fun u v -> compare v u) a in
    let mid =
        List.fold_left (fun acc elem ->
            let v1 = abs_float (float_of_int elem -. (float_of_int max /. 2.)) in
            let v2 = abs_float (float_of_int acc  -. (float_of_int max /. 2.)) in
            if v1 < v2 then elem else acc
        ) max2 a
    in
    Printf.printf "%d %d\n" max mid
