main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ai <- map (read :: String -> Int) . words <$> getLine
  print $ ans ai

ans :: [Int] -> Int
ans ai = (\(_,xs) -> maximum xs) $ foldl func (0,[]) ai where
  func (h,xs) k = (gcd h k,func2 $ h : foldl (\acc l -> if gcd k l == 1 then acc else gcd k l : acc) [] xs)
  func2 [] = []
  func2 (x:[]) = [x]
  func2 (x1:x2:xs)
    | mod x1 x2 == 0 = func2 (x1:xs)
    | mod x2 x1 == 0 = func2 (x2:xs)
    | otherwise = x1 : func2 (x2:xs)