#include <utility>
#include <algorithm>
#include <iostream>
using namespace std;

int T, N, K, X[100000+10], A[100000+10];
int main() {
  int sum;
  cin >> T; // Read-in T, the number of data sets
  for (int t=0; t<T; ++t) {
    cin >> N >> K; // Read N, number of houses, K, number of generators
    for (int i=0; i<N; ++i) cin >> X[i]; // the locations of houses
    for (int i=0; i+1<N; ++i) A[i] = X[i+1]-X[i]; // distance between houses
    sort(A, A+N-1);
    sum = 0; // initialize sum as 0
    for (int i = 0; i < N-K; ++i) sum += A[i];
    cout << sum << endl;
  }
}