import Control.Monad.ST import Control.Monad import Data.Array.ST import Data.Array import Data.STRef import Control.Monad import Control.Applicative import Data.List getMin a b | a<0 && b<0 = negate a | a>0 && b>0 = b | otherwise = (b-a) + min (negate a) b ans n (a:as) c | c < n = 800000000 | otherwise = min (getMin a ((a:as) !! (n-1))) (ans n as (c-1)) main = do [n,m] <- map read <$> words <$> getLine ::IO [Int] b <- sort <$> map read <$> words <$> getContents ::IO [Int] print $ ans n b m