import Data.List

solver::[Int]->Int->Int->Int
solver ls n m = sum (take (m-n) (dif ls))

dif::[Int]->[Int]
dif ls = let srtd = sort ls in sort (map (\(a,b)->(a-b)) (zip (tail srtd) srtd))

main::IO()
main=do
  (n:m:_)<-(return.(map read).words)=<<getLine
  ls<-(return.(map read).words)=<<getLine
  print (solver ls n m)