import Control.Applicative ((<$>)) import qualified Data.ByteString.Lazy.Char8 as LC import qualified Data.IntSet as IS import Data.Maybe (fromJust) unsafeReadInt :: LC.ByteString -> Int unsafeReadInt = fst . fromJust . LC.readInt diff :: Num a => [a] -> [a] diff xs = zipWith (-) (tail xs) (init xs) findMin :: [Int] -> Int findMin xs | IS.size ys < 2 = 0 | otherwise = minimum . diff . IS.toAscList $ ys where ys = IS.fromList xs main :: IO () main = do _ <- getLine xs <- fmap unsafeReadInt . LC.words <$> LC.getContents print $ findMin xs