#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define MP make_pair
#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n)  for(int i=0;i<(n);++i)
using namespace std;
typedef pair<int,int> P;
int main(){
	int times;
	cin>>times;
	REP(i,times){
		int n,k;
		cin>>n>>k;
		int x[100100];
		REP(j,n)cin>>x[j];
		vector<int>v;
		REP(j,n-1){
			v.PB(x[j+1]-x[j]);
		}
		sort(ALL(v));
        reverse(ALL(v));
        int btw=x[n-1]-x[0];
        REP(j,min(n-1,k-1)){
            btw-=v[j];
        }
        cout<<max(0,btw)<<endl;
    }
}


