def reader(x)
  x.split(" ").map(&:to_i)
end

def solve(xs, n, k)
  edges = {}
  (k - 1).times do
    xs[0..-2].zip(xs[1..-1])
      .map.with_index { |x, i|
      [i, x[1] - x[0]]
    }.sort_by {|v| v[1]}.reverse.each do |i, v|
      next if (edges.key?(i) or edges.key?(i - 1)) # check edge
      edges[i] = v
      break
    end
  end
  values = edges.values
  (xs[-1] - xs[0]) - (values.empty? ? 0 : values.reduce(&:+))
end
data = $stdin.read.split("\n")
data[1..-1].each_slice(2) do |num, items|
  n, k = reader(num)
  xs = reader(items)
  puts solve(xs, n, k)
end