
times = gets.chomp.to_i
for t in 0..times-1
	nk = gets.chomp.split()
	n = nk[0].to_i
	k = nk[1].to_i

	ary = gets.chomp.split()

	margin = Array.new
	ary[0] = ary[0].to_i
	for i in 0..n-2
		ary[i+1] = ary[i+1].to_i
		margin.push(ary[i+1] - ary[i])
	end
	margin.sort!
	#p ary,margin,n,k 					#?¢??????¨
	sum = 0
	for j in 0..n-1-k
		sum += margin[j]
	end
	puts sum
end