(gets.to_i).times{
  n, k = gets.split(" ").map{|str| str.to_i}
  a = gets.split(" ").map{|str| str.to_i}
  if n>1 && n>k
    l = a[-1]-a[0]
    d = Array.new(n-1){|i| a[i+1]-a[i]}.sort
    (k-1).times{l -= d[-1] ; d = d[0..-2]}
    puts l
  else
    puts 0
  end
}