N, M = gets.chomp.split().map(&:to_i)
X = gets.chomp.split().map(&:to_i).sort

X_pad = []
(M-1).times do |i|
  X_pad << X[i+1] - X[i]
end

X_pad.sort!
ans = 0
(M - 1 - (N - 1)).times do |i|
  ans += X_pad[i]
end

puts ans
