import Data.Array
import Data.List

--必要判定、
is_need::Int -> Int -> Array Int Int -> Bool
is_need　idx k stdar = let table = make_tab idx k stdar in
                       let upp = k-1 in
                       let und = max (k-(stdar!idx)) 0 in
                       or [table!((fst.snd.bounds)table,t)|t<-(if und<=upp then [und..upp] else [])]

--iを使わないでj番目まででlを作れるか配列
make_tab::Int -> Int -> Array Int Int -> Array (Int,Int) Bool
make_tab idx k stdar = let n = snd (bounds stdar) in
                      listArray ((0,0),(n,k-1)) [if a == 0 then (b == 0)
                                                           else (rec (a-1) b)||(rec (a-1) (not_minu b (expt a) ))
                                                           |a<-[0..n],b<-[0..(k-1)]]
                      where expt j  = if j == idx then 0 else (stdar!j)
                            not_minu x y = if y<= x then (x-y) else x
                            rec a b = (make_tab idx k stdar)!(a,b)

--必要な要素が始まるインデックスを二分探索
bin_cut::Array Int Int -> Int -> Int
bin_cut stdar k = let (st,ed) = bounds stdar in
               if (is_need st k stdar) then 1
                                       else if not (is_need ed k stdar) then (ed+1)
                                                                        else rec st ed
               where rec a b = if a+1 == b then b
                                           else let mid = div (a+b) 2 in
                                                if is_need mid k stdar then rec a mid else rec mid b

solver::Array Int Int -> Int -> Int
solver stdar k = (bin_cut stdar k)-1


main::IO()
main=do
  nkc<-getLine
  let n:k:[]=map read (words nkc)
  dat<-getLine
  let stdar = listArray (1,n) (sort (map read (words dat))::[Int])
  print (solver stdar k)
