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

int main(){
  int t,n,k,ans;
  int x[100000],d[100000];
  cin >> t;

  while(t--){
    cin >> n >> k;
    for(int i=0;i<n;i++){
      cin >> x[i];
      if(i)d[i-1] = x[i] - x[i-1];
    }
    if(n<=k)cout << 0 << endl;
    else{
      ans = x[n-1]-x[0];
      sort(d,d+n-1);

      int tmp = 1;
      while(k!=tmp)ans -= d[n-1-tmp++];
      cout << ans << endl;
    }
  }
}