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

int dp[110][110];
int a[110];

int main()
{
	ios::sync_with_stdio(false);
	int n, m, T;
	cin >> T;
	for (int cas = 1; cas <= T; cas++){
		cin >> n >> m;
		for (int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + n + 1);
		memset(dp, -1, sizeof(dp));
		dp[0][0] = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j <= n; j++) {
				if (dp[i][j] == -1) continue;
				for (int k = j + 1; k <= n; k++) {
					if (dp[i + 1][k] == -1 || dp[i + 1][k] > dp[i][j] + a[k] - a[j + 1]) 
						dp[i + 1][k] = dp[i][j] + a[k] - a[j + 1];
				}
			}
		}
		printf("Case #%d: %d\n", cas, dp[m][n]);
	}
	return 0;
}

