#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()
#define allof(a) (a).begin(),(a).end()

int main() {
	int T;
	cin >> T;
	
	for_(i,0,T) {
		int n, k, prv, sum = 0;
		cin >> n >> k;
		cin >> prv;
		
		priority_queue< int > que;
		
		for_(i,1,n) {
			int cur; cin >> cur;
			int diff = cur - prv;
			que.push(diff);
			sum += diff;
			prv = cur;
		}
		
		for_(i,1,k) {
			if (que.empty()) break;
			int t = que.top(); que.pop();
			sum -= t;
		}
		
		cout << sum << endl;
	}
}