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(k-1, 0)
  n.times do |i|
    prev = now
    now = data[i]
    tmp = now -prev
    (k-1).times do |i|
      if (tmp < min)
        break
      elsif (tmp > hoge[i])
        if i == 0
          hoge = Array.new(1,tmp) + hoge.slice(0..k-2)
          min = hoge[k-1]
          break
        elsif
          hoge = hoge.slice(0..(i-1)) + Array.new(1,tmp) + hoge.slice(i..(k-2))
          min = hoge[k-1]
          break
        end
      end
    end
  end
  a = data[n-1] - data[0]
  (k-1).times do |i|
    a -= hoge[i]
  end
  a = 0 if a < 0
  p a
end