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

if n >= m
    puts 0
else
    ary.sort!
    sabun = []
    (m-1).times do |i|
        sabun << ary[i+1] - ary[i]
    end
    # p sabun
    sabun.sort! {|a, b| b <=> a }
    # p sabun
    (n-1).times do |i|
        sabun.shift
    end
    # p sabun
    ans = sabun.inject(:+)
    puts ans
end