t = gets.to_i
t.times do
  str = gets.split()
  n = str[0].to_i
  k = str[1].to_i
  d = gets.split()
  data = Array.new(n, 0)
  n.times do |i|
    data[i] = d[i].to_i
  end
  prev = 0
  now = 0
  min = 0
  hoge = Array.new(n-1, 0)
  n.times do |i|
    prev = now
    now = data[i]
    tmp = now - prev
    next if i == 0
    hoge[i-1] = tmp
  end
  hoge.sort!
  hoge.reverse!
  a = data[n-1] - data[0]
  if n > k
    (k-1).times do |i|
      a -= hoge[i]
    end
  else
   a = 0
  end
  a = 0 if a < 0
  p a
end