import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> readLine >>= print . solve

solve :: [Int] -> Int
solve = calc . sort
    where
        calc (x : y : zs)
            | m == 0 = calc $ x : zs
            | otherwise = calc $ m : x : zs
            where
                (r, m) = y `divMod` x
        calc [x] = x

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

