import Data.List
main :: IO()
main = do
  _ <- getLine
  a <- map read . words <$> getLine
  print $ slv a

slv :: [Integer] -> Integer
slv a | length a == 2 = maximum a
      | otherwise = proc (cycle a) (length a - 2) (length a) 0
 
proc :: [Integer] -> Int -> Int -> Integer -> Integer
proc _ _ 0 ret = ret
proc (a:as) len n ret = proc as len (n-1) (max ret gcds)
  where gcds = foldl (gcd) a (take len as)
