#include <stdio.h>
#include <stdlib.h>

int n,k;
int x[100000];
int length[100000];

int qsort_comp(const void* x,const void* y) {
	int* a=(int*)x;
	int* b=(int*)y;
	if(*a<*b)return 1;
	if(*a>*b)return -1;
	return 0;
}

int main(void) {
	int d_num,cur_d;
	int i,sum;
	scanf("%d",&d_num);
	for(cur_d=0;cur_d<d_num;cur_d++) {
		scanf("%d%d",&n,&k);
		for(i=0;i<n;i++)scanf("%d",&x[i]);
		for(i=0;i<n-1;i++)length[i]=x[i+1]-x[i];
		qsort(length,n-1,sizeof(int),qsort_comp);
		sum=0;
		for(i=k-1;i<n-1;i++)sum+=length[i];
		printf("%d\n",sum);
	}
	return 0;
}