#include<iostream>
#include<algorithm>
#include<functional>
int p[100000],df[100001];
int n, k, w = 0;
int main(){
	int t;
	std::cin >> t;
	for (int i = 0; i < t;i++){
		w = 0;
		std::cin >> n >> k;
		for (int i = 0; i < n; i++){
			std::cin >> p[i];
			if (i != 0)df[i - 1] = p[i] - p[i - 1];
		}
		std::sort(df, df + n - 1, std::greater<int>());
		for (int i = 0; i < k - 1; i++){
				w += df[i];
		}
		if (n <= k || n == k){
			std::cout << 0 << "\n";
		}
		else if (n == 2){
			std::cout << p[n - 1] << "\n";
		}
		else{
			std::cout << (p[n - 1] - p[0]) - w << "\n";
		}
	}
}