t = gets.to_i
t.times {
    n, k = gets.split.map &:to_i
    break if n == 0
    xs = gets.split.map &:to_i
    lengths = (0..n-2).map{|i| xs[i+1] - xs[i]}
    if n - k > 0
        p lengths.sort[0..n-k-1].inject(0, :+)
    else
        p 0
    end
}