N=io.read("n")
M=io.read("n")
t={}
for i=1,M do 
  t[i]=io.read("n")
end
if N>=M then 
  print(0)
  else
	table.sort(t)
	r={}
	for i=1,M-1 do
  		r[i]=t[i+1]-t[i]
	end
	table.sort(r)
	s=0
	for i=1,M-N do 
    	s=s+r[i]
    end
  	print(s)
end