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

int comp(const void* a, const void* b);

int main() {
	int t,n, k,i, j;
	int *x,*ans,*bou;
	scanf("%d", &t);
	ans = (int*)malloc(t * sizeof(int));
	for (i = 0; i < t; i++) {
		ans[i] = 0;
		scanf("%d%d", &n, &k);
		x = (int*)malloc(n * sizeof(int));
		bou = (int*)malloc((n - 1) * sizeof(int));
		for(j=0;j<n;j++)scanf("%d", &x[j]);
		if (k >= n)ans[i] = 0;
		else {
			for (j = 0; j < n - 1; j++) {
				bou[j] = x[j + 1] - x[j];
			}
			qsort(bou, n - 1, sizeof(int), comp);
			for (j = k-1 ; j < n - 1; j++)ans[i] += bou[j];
		}
	}
	for (i = 0; i < t; i++) {
		printf("%d\n", ans[i]);
	}

	return 0;
}

int comp(const void* a, const void* b) {
	return *((int*)b) - *((int*)a);
}