n, m = gets.split.map(&:to_i)

if n >= m
  puts 0
else
  points = gets.split.map(&:to_i).sort

  spaces = []
  points.each_with_index do |e, i|
    break if i == points.size - 1
    spaces << points[i + 1] - e
  end

  spaces.sort!

  (n - 1).times do
    spaces.pop
  end

  puts spaces.inject(&:+)
end
