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

int main() {
  int n,k,t,l;
  cin>>t;
  while(t--) {
    cin>>n>>k;
    vector<int> x;
    for(int i=0; i<n; ++i) {
      cin>>l;
      x.push_back(l);
    }

    priority_queue< int ,vector<int>, greater<int> > Q;
    for(int i=0; i<n-1; ++i) {
      Q.push(x[i+1] - x[i]);
    }

    long long ans = 0;
    while(n-k>0) {
      ans += Q.top();
      Q.pop();
      n--;
    }
    cout<<ans<<endl;
  }
}