t = gets().chop.to_i

t.times do
	n, k = gets().chop.split(" ").map{|num| num.to_i}
	x = gets().chop.split(" ").map{|num| num.to_i}
	a = Array.new(n - 1)
	for i in 0..n - 2
		a[i] = x[i + 1] - x[i]
	end
	a.sort!
	if 0 >= n - 1 - (k - 1)
		p 0
	else
		p a.take(n - 1 - (k - 1)).inject(:+)
	end
end