import Data.List

f k (hs, cs) h = (take k (h:hs), take k (c:cs))
  where
    c = minimum $ zipWith (+) cs $ fmap (abs . (h-)) hs


main = do
    let read' = fmap ((map read) . words) getLine
    [n, k] <- read' 
    (h:hs) <- read'
    print $ (head . snd) $ foldl' (f k) ([h], [0]) hs