#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

long long n, k, m, x[100010], d[100010], result, l = 0;
int main(){
	int t;
	cin >> t;
	for (int i = 0; i < t; i++){
		result = 0;
		cin >> n >> k;
		for (int j = 0; j < n; j++){ cin >> x[j]; }
		for (int j = 0; j + 1 < n; j++){ d[j] = x[j + 1] - x[j]; }
		sort(d, d + n - 1);
		m = max(l, n - k);

		for (int j = 0; j < m; j++)
			result += d[j];
		cout << result << endl;

	}
}