#include <iostream>
#include <algorithm>

using namespace std;
int main(){
	int n,k,dis[100010],a,before,tmp,ans;
	
	for(cin>>a;a>0;a--){
		ans=0;
		cin>>n>>k;
		cin>>before;
		for(int i=1;i<n;i++){
			cin>>tmp;
			dis[i-1]=tmp-before;
			before=tmp;
		}
		sort(dis,dis+n-1);
		
		
		for(int i=0;i<n-k;i++)ans+=dis[i];
		
		cout<<ans<<endl;
	}
}