import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

main = do
    [n,x] <- map read . words <$> getLine
    xs <- VU.fromList . sort . (x:) . VU.toList . VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ snd $ VU.foldl' (\(prev, dist) x -> let d = abs $ prev - x in (x, min dist d)) (10^9+7, 10^9+7) xs