(* O(log(n)) (n = max {a, b}) *)
let rec gcd a b = if b = 0 then a else gcd b (a mod b)

(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

(* O(|ns| * log(max ns)) *)
let gcd_info ns =
  let n = Array.length ns in
  let front = Array.make n 0 in
  let _ = fold_int (fun g i -> let g1 = gcd g ns.(i) in front.(i) <- g1; g1) 0 n in
  let back = Array.make n 0 in
  let _ = fold_int (fun g i -> let g2 = gcd g ns.(n - 1 - i) in back.(n - 1 - i) <- g2; g2) 0 n in
  (front, back)

(* O(log(m)) (m = max {max front, max back}) *)
let excluded_gcd i n front back =
  let front_g = if i <= 0 then 0 else front.(i - 1) in
  let back_g = if i >= n - 1 then 0 else back.(i + 1) in
  gcd front_g back_g

(* O(n * log(max a_s)) *)
let solve n a_s =
  let front, back = gcd_info (Array.of_list a_s) in
  let gcds = fold_int (fun acc i -> excluded_gcd i n front back :: acc) [] n in
  List.fold_left max 0 gcds

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ = let n = read_int () in read_ints () |> solve n |> string_of_int |> print_endline