let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let lst = Array.to_list (Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))) in
  let buf_lst = (List.tl lst) @ [List.hd lst] in
  let ans_lst = List.map2 (fun a b -> gcd a b) lst buf_lst in
  Printf.printf "%d\n" (List.fold_left max min_int ans_lst)
