N , M = gets.split.map!{|i| i.to_i}

x = gets.split.map!{|i| i.to_i}
x.sort!

sum = 0
min = 0

if N >= M 
    puts 0
else
    l = Array.new(M-1,0)
    for i in 1..x.size-1
        l[i-1] = x[i] - x[i-1]
    end

    l.sort!{|a,b| -a <=> -b}

    for i in 0..N-2
        sum += l[i]
    end

    puts x[x.size-1] - x[0] - sum
end