// AOJ 2104: Country Road
// 2017.9.30

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

int d[100002];

char buf[800000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

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

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

	fgets(p=buf, 10, stdin), t = getint();
	while (t--) {
		fgets(p=buf, 20, stdin), n = getint(), p++, k = getint();
		fgets(p=buf, sizeof(buf), stdin);
		if (k >= n) { puts("0"); continue; }
		for (n--, x0 = getint(), i = 0; i < n; i++, x0 = x) {
			p++, x = getint();
			d[i] = x - x0;
		}
		qsort(d, n, sizeof(int), cmp);
		for (ans = 0, i = 0; i <= n-k; i++) ans += d[i];
		printf("%d\n", ans);
	}
	return 0;
}