import Data.Array
import Control.Monad
import Data.IORef
main = do
  length <- readLn
  as <- listArray (1,length) . map read . words <$> getLine
  maxGCDRef <- newIORef (gcdAll 0 . tail $ elems as) :: IO (IORef Int)
  _ <- forM [2..length] $ \n -> do
    let as' = [as ! x| x <- [1..length], x /= n]
    maxGCD <- readIORef maxGCDRef
    writeIORef maxGCDRef (maxGcdAll maxGCD 0 as')
  print =<< readIORef maxGCDRef
  
gcdAll 0 (x:y:zs) = gcdAll (gcd x y) zs
gcdAll acc [] = acc
gcdAll acc (x:xs) = gcdAll (gcd acc x) xs

maxGcdAll :: Int -> Int -> [Int] -> Int
maxGcdAll maxGCD 0 (x:y:zs) = maxGcdAll maxGCD (gcd x y) zs
maxGcdAll maxGCD acc [] = max maxGCD acc
maxGcdAll maxGCD acc (x:xs)
  | maxGCD > acc = maxGCD
  | otherwise = maxGcdAll maxGCD (gcd acc x) xs