let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let l = Array.init n (fun i -> a.(i)) in
  for i = 1 to n-1 do l.(i) <- gcd a.(i) l.(i-1) done;

  let r = Array.init n (fun i -> a.(i)) in
  for i = n-2 downto 0 do r.(i) <- gcd a.(i) r.(i+1) done;

  Array.init n (fun i -> 
    if i = 0 then r.(1) else if i = n-1 then l.(n-2)
    else gcd l.(i-1) r.(i+1))
  |> Array.fold_left max 0
  |> Printf.printf "%d\n"
