local read = io.read

local n, m = read("n", "n")

if n >= m then
	print(0)
	os.exit()
end

local x_t = {}
for i = 1, m do
	x_t[i] = read("n")
end
table.sort(x_t)
local distance_t = {}
for i = 1, m - 1 do
	distance_t[i] = x_t[i + 1] - x_t[i]
end
table.sort(distance_t, function(x, y) return x > y end)
local out = x_t[#x_t] - x_t[1]
for i = 1, n - 1 do
	out = out - distance_t[i]
end

print(out)
