main = do
    n <- readLn
    xs <- map (read::String -> Int) . words <$> getLine
    print $ maximum (func n (take (n * 2 - 2) $ cycle xs))

func :: Int -> [Int] -> [Int]
func n (x:xs) = if n > 0
                    then foldr1 gcd xs:(func (n-1) (xs++[x]))
                    else []

