N, M = gets.split.map(&:to_i)
Xs = gets.split.map(&:to_i)
ans = 0

Xs.sort!
tmp = []
(Xs.length - 1).times{|x|
    tmp[x] = Xs[x+1] - Xs[x]
}
tmp.sort!

if (M-N) > 0
    ans = tmp[0..(tmp.length- 1 - (N-1))].inject{|sum,n| sum+n}
end

puts ans
