import Control.Monad
import Control.Monad.ST
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV

main = B.interact$B.pack.show.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:k:h) = minimum $ zipWith (\s h->h-s) ss hs
    where
        hh = sort h
        ss = take (n-k+1) hh
        hs = drop (k-1) hh