// AOJ 2104: Country Road
// 2017.9.30

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

int x[100002];
int d[100002];

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

int main()
{
	int t, n, k, i, ans;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%d%d", &n, &k);
		for (i = 0; i < n; i++) scanf("%d", x+i);
		if (k >= n) { puts("0"); continue; }
		for (n--, i = 0; i < n; i++) d[i] = x[i+1]-x[i];
		qsort(d, n, sizeof(int), cmp);
		for (ans = 0, i = 0; i <= n-k; i++) ans += d[i];
		printf("%d\n", ans);
	}
	return 0;
}