import Data.List rInt :: String -> Int rInt = read solve n xs | n == 1 || length xs == 1 = 0 | otherwise = minimum $ zipWith (-) (tail xs) (init xs) main = do n <- rInt <$> getLine xs <- map head . group . sort . map rInt . words <$> getLine print $ solve n xs