import Data.List
main=do
 [n,m]<-map read.words<$>getLine
 x<-sort.map read.words<$>getLine
 print(g n (f m x))
  where g n l =sum (drop(n-1)(reverse(sort l)))
        f 1 _ =[]
        f m (a:b:x) =(b-a):(f(m-1)(b:x))