t = gets.to_i
ret = []
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]
  ret << (a.empty? ? "0" : a.reduce(:+))
end
puts ret