import Data.List

solve xs 
    | length xs == 1 = head xs
    | otherwise = solve xs'
    where
        xs' = sort $ foldl' step [head xs] (tail xs)
        step (y:ys) z
            | r == 0 = (y:ys) 
            | otherwise = (r:y:ys)
                where
                    r = z `rem` y

main = do 
    getLine
    xs <- sort . map read . words <$> getLine :: IO [Int]
    print $ solve xs