import Control.Monad import Data.List import Data.Char (isSpace) import qualified Data.ByteString.Char8 as B8 main :: IO () main = do B8.getLine solve <$> readIntList >>= print solve :: [Int] -> Int solve xs = case f 100000000 (sort xs) of 100000000 -> 0 x -> x where f mn (x:y:ys) | x == y = f mn (y:ys) | otherwise = f (min mn (y - x)) (y:ys) f mn _ = mn readIntList :: IO [Int] readIntList = unfoldr f <$> B8.getLine where f s = do (n, s') <- B8.readInt s return (n, B8.dropWhile isSpace s')