t=gets.to_i
t.times{
    n,k = gets.split.map &:to_i
    x = gets.split.map &:to_i
    d = []
    (0..x.size-2).each{|i|
        d << x[i+1] - x[i]
    }
    puts x[-1] - x[0] - d.sort.reverse.slice(0,k-1).sum
}
