N, M = gets.strip.split(/\s+/).map(&:to_i)
puts(0) and exit if N >= M
i = gets.strip.split(/\s+/).map(&:to_i).sort
d = i.each_cons(2).map{|a,b| b-a }
di = d.length.times.sort_by{|i| d[i] }
puts di.take(di.length-N+1).inject(0){|sum,i| sum+d[i] }
