open Printf open Scanf
open Array

let rec gcd m n = match m,n with | m,0 -> m | m,n -> gcd n (m mod n)

let print_array f a = Array.iter (fun v -> printf "%s " @@ f v) a; print_newline ()

let () = scanf " %d" @@ fun n ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v) in
  let lr = make n a.(0) in
  let rl = make n a.(n-1) in
  for i=1 to n-1 do
    lr.(i) <- gcd lr.(i-1) a.(i)
  done;
  for i=n-2 downto 0 do
    rl.(i) <- gcd rl.(i+1) a.(i)
  done;
  (* print_array string_of_int lr;
  print_array string_of_int rl; *)
  init n (fun i ->
    let w =
      if i=0 then rl.(1)
      else if i=n-1 then lr.(n-2)
      else gcd rl.(i+1) lr.(i-1)
    in w)
  |> fold_left max 0
  |> print_int

