gets.to_i.times do
  n,k = gets.split.map(&:to_i)
  xs = gets.split.map(&:to_i)
  d = Array.new(n - 1) do |i|
    xs[i + 1] - xs[i]
  end
  d.sort!.reverse!
  ans = xs[-1] - xs[0]
  a = [n, k].min - 1
  ans -= d[0, a].inject(:+) if a > 0
  p [ans, 0].max
end