#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int t, n, k;

int main(void) {
  cin >> t;
  while(t--) {
    cin >> n >> k;
    vector<int> x, y;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      x.push_back(tmp);
      if (i >= 1) y.push_back(tmp-x[x.size()-2]);
    }
    int ans = x[n-1] - x[0];
    sort(y.begin(), y.end());
    if (k > n) k = n;
    for (int i = 0; i < k-1; i++) {
      ans -= y[y.size()-1-i];
    }
    cout << ans << endl;
  }
  return 0;
}
  