constint N = 105; int n, k; int a[N], b[N]; boolcmp(int a, int b) { return a > b; } voidsolve() { cin >> n >> k; for (int i = 1; i <= n; i ++) cin >> a[i]; for (int i = 2; i <= n; i++) { b[i] = abs(a[i] - a[i - 1]); } sort(b + 2, b + 1 + n); int ans = 0; for (int i = 2; i <= n - k + 1; i ++) ans += b[i]; cout << ans << endl; } signedmain() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { solve(); } return0; }