t = gets.to_i / 2
t.times do
  n, k = gets.split.map(&:to_i)
  xs = gets.split.map(&:to_i)
  ds = (xs.size - 1).times.map {|i| xs[i + 1] - xs[i] }.sort
  a = ds[0..-k]
  puts a.empty? ? "0" : a.reduce(:+)
end