import Control.Applicative

inputs = fmap (read :: String -> Int) . words <$> getLine
input = (read :: String -> Int) <$> getLine

tuples n lst = do
    x <- [0..n-1]
    y <- [x+1..n-1]
    return (abs $ (lst !! x) - (lst !! y))

solve n xs = minimum $ tuples n xs

main = input >>= \n -> if n /= 0 then 
                                 inputs >>= (\xs -> putStrLn $ show $ solve n xs) >> main
                                 else do return ()