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

int n, k;
int t[100002];

int main(){
  int T;
  cin >> T;

  while(T--){
    vector<int> vec;

    cin >> n >> k;
    k = min(k, n);

    for(int i = 0; i < n; i++){
      cin >> t[i];
      if(i != 0) vec.push_back(t[i] - t[i - 1]);
    }

    sort(vec.begin(), vec.end());

    int ans = 0;
    for(int i = 0; i < n - k; i++){
      ans += vec[i];
    }
    cout << ans << endl;
  }
}