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

int interval[100000 - 1];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;

    int begin, end, left;
    cin >> begin;
    left = end = begin;
    for (int i = 0; i < n - 1; i++) {
      cin >> end;
      interval[i] = end - left;
      left = end;
    }
    sort(interval, interval + n - 1, greater<int>());

    int total = end - begin;
    for (int i = 0; i < k - 1 && i < n - 1; i++) total -= interval[i];
    cout << total << endl;
  }
  return 0;
}