
int N;
long n, k;
long x[100000];
long dist[100000];
long result;

long cmp(const long *a, const long *b){
	return *b - *a;
}

int main(){
	long i;
	scanf("%d", &N);
	while(N--){
		scanf("%d%d", &n, &k);
		scanf("%d", &x[0]);
		for(i = 1; i < n; i++){
			scanf("%d", &x[i]);
			dist[i-1] = x[i] - x[i-1];
		}
		qsort(dist, n-1, sizeof(long), (long (*)(const void*, const void*))cmp);
		result = x[n-1] - x[0];
		if(n <= k){
			result = 0;
		}else{
			for(i = 0; i < k-1; i++){
				result -= dist[i];
			}
		}
		printf("%d\n", result);
	}
	return 0;
}